Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use 'succeed do' in haml?

Tags:

haml

I used html2haml.heroku.com and it turned some ordinary strings into the following:

A normal sentence is here
= succeed '.' do
  %strong and it is cut off randomly by this succeed

Where the succeed call seems unnecessary. Is this just an artifact from the html to haml conversion?

like image 892
Clucking Turtle Avatar asked Apr 30 '13 02:04

Clucking Turtle


People also ask

How to write comments in HAML?

Haml Comments: -#The hyphen followed immediately by the pound sign signifies a silent comment. Any text following this isn't rendered in the resulting document at all.

How does HAML work?

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.


1 Answers

If you try

A normal sentence is here
= succeed '.' do
  %strong and it is cut off randomly by this succeed

and generate the HTML, the output will be like this:

A normal sentence is here
<strong>and it is cut off randomly by this succeed</strong>.

However, if you try something like

A normal sentence is here
%strong and it is cut off randomly by this succeed
.

You will have an output like this:

A normal sentence is here
<strong>and it is cut off randomly by this succeed</strong>
.

And white spaces are important in inline elements - please refer to my (late) answer in this question

like image 186
fotanus Avatar answered Oct 19 '22 05:10

fotanus