How can I start a line with a percent in HAML file?
This doesn't work:
%p
= my_ruby_var
%
=== UPDATE ===
Note: This answer is not accepted. I don't want any ruby to be computed:
%p
= my_ruby_var
= '%'
=== UPDATE 2 ===
For info: I discovered in the same doc reference that it is also possible to escape HTML as well:
An ampersand followed by one or two equals characters evaluates Ruby code just like the equals without the ampersand, but sanitizes any HTML-sensitive characters in the result of the code.
For example:
&= "I like cheese & crackers"
compiles to
I like cheese & crackers
In Haml, we write a tag by using the percent sign and then the name of the tag. This works for %strong , %div , %body , %html ; any tag you want. Then, after the name of the tag is = , which tells Haml to evaluate Ruby code to the right and then print out the return value as the contents of the tag.
HTML Comments: /The forward slash can also wrap indented sections of code. For example: / %p This doesn't render... %div %h1 Because it's commented out!
What is it? Haml (HTML abstraction markup language) is based on one primary principle: markup should be beautiful. It's not just beauty for beauty's sake either; Haml accelerates and simplifies template creation down to veritable haiku.
Haml (HTML Abstraction Markup Language) is a templating system that is designed to avoid writing inline code in a web document and make the HTML cleaner.
try
\%
maybe..
because it said in http://haml.info/docs/yardoc/file.REFERENCE.html#escaping_ that \ is the escape character
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With