2sr8uq
Last Updated: January 22, 2019
·
20.86K
· javiercr

Mixing text and variables with HAML

I see a lot of people using HAML and doing things like this:

%p
  Lorem ipsum
  = variable
  dolor sit amet

Or even this:

%p= "Lorem ipsum #{variable} dolor sit amet"

However, mixing text (strings) and variables with HAML is pretty much easier and cleaner using HAML/Ruby interpolation like this:

%p Lorem ipsum #{variable} dolor sit amet

You can do it with multi line text too:

%p 
  Lorem ipsum #{variable} dolor sit amet
  consectetur adipisicing elit, sed do eiusmod

Hope it helps! Happy HAML coding!