In my Ruby on Rails Project I use HAML, I need to translate something like this
<div>foo <a>bar</a>.<div>
into HAML. It should look like:
.divclass foo %a bar .
The period at start is not working because its used by HAML. So how can I use a period as content?
Even with building a span around its not working, again the period is taken as something special.
I think there is an escape mechanism but I can't find it.
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.
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. Haml gives the flexibility to have some dynamic content in HTML.
It is escaped with \
like this
\.
See Escaping \ in the HAML reference.
Update: Using HAML's succeed
(as in this answer) is a better solution if you need a dot in the end of the sentence (to prevent unnecessary white space).
A better method:
%p This sentence ends with a link which is *just* before a period = succeed "." do %a{:href => "#"} link But the period wasn't included with the link and there was no space before the period.
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