2sr8uq
Last Updated: February 25, 2016
·
14.98K
· javiercr
Wh3vnhu1e1g0hdfuxhnc

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!

Say Thanks
Respond