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!
Written by Javier Cuevas
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#