Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use br tag in haml?

Tags:

haml

I have been trying <br> tag in haml, very unfortunately none of my code are working. How should we use nest for <br> in haml ?

%h1 Helo mate 
  %br/ 
  whrere are you ?
like image 534
Mo. Avatar asked Dec 01 '15 11:12

Mo.


People also ask

How to use 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.


1 Answers

Your example (%br/) already seems to be correct. Whether you get a selfclosing tag (<br />) or a standalone tag (<br>) depends on whether your code is interpreted as html or as xhtml, so check which format you need. Xhtml has problems with non-closing tags.

Look here for more info.

Edit: Adding the info from matt's comment. The problem is not the br tag, but the content of the h1 tag being on the same line as the tag as well as on the next line, while the whole content should be nested when the content is more than one line:

%h1
  Hello mate 
  %br/ 
  where are you?
like image 144
Raimund Krämer Avatar answered Oct 11 '22 16:10

Raimund Krämer