Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I write a percent sign (%) at the beginning of a line in HAML?

Tags:

escaping

haml

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
like image 317
Douglas Avatar asked Dec 03 '12 23:12

Douglas


People also ask

How do you write Haml in HTML?

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.

How do you write comments in Haml?

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 Haml in CSS?

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.

What is Haml language?

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.


1 Answers

try

\%

maybe..

because it said in http://haml.info/docs/yardoc/file.REFERENCE.html#escaping_ that \ is the escape character

like image 69
Kokizzu Avatar answered Sep 27 '22 19:09

Kokizzu