Can you manually insert a line break at the end of a line?

7,308 views
Skip to first unread message

Andrew Burleson

unread,
Dec 17, 2010, 12:18:47 AM12/17/10
to Haml
Here's what I *want*

.fooclass
This is some text that I want inside this div. <br />
Because there's going to be some wrapping going on I want to
control where line breaks are rendered. <br />

Now, sticking those br tags doesn't do anything obviously.

If I put
.fooclass
Line one goes here
%br Line two goes here
%br Line three goes here

... then it *kinda* works, but it's rendering like this: "<br>Line two
goes here</br>" ... which is totally bogus.

I can put
.fooclass
Line one
%br/
Line Two
%br/
Line Three

... but I'd hardly call that Markup Haiku!!

There has to be a better way to manually control the rendering of line
breaks, but I haven't been able to find it. Help??

Nathan Weizenbaum

unread,
Dec 17, 2010, 11:34:26 AM12/17/10
to haml
You can just include "<br />" as part of your text.


--
You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to ha...@googlegroups.com.
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.


Andrew Burleson

unread,
Dec 17, 2010, 11:59:43 AM12/17/10
to ha...@googlegroups.com
... wow. Ok, so that does work.

I thought that the "/" character made everything after that a comment, and my syntax highlighting indicates as much. Why doesn't that happen when you're closing a tag?

Nathan Weizenbaum

unread,
Dec 17, 2010, 12:24:53 PM12/17/10
to haml
"/" only makes comments when it's at the beginning of the line. The same is true for almost all characters Haml cares about. The only exception is #{}.

Andrew Burleson

unread,
Dec 17, 2010, 12:55:55 PM12/17/10
to ha...@googlegroups.com
*doh*

Ok, thanks, that makes tons of sense. I appreciate the help!

Gunnar Wolf

unread,
Dec 20, 2010, 1:29:41 PM12/20/10
to ha...@googlegroups.com
Andrew Burleson dijo [Thu, Dec 16, 2010 at 09:18:47PM -0800]:

> Here's what I *want*
>
> .fooclass
> This is some text that I want inside this div. <br />
> Because there's going to be some wrapping going on I want to
> control where line breaks are rendered. <br />
>
> Now, sticking those br tags doesn't do anything obviously.
>
> If I put
> .fooclass
> Line one goes here
> %br Line two goes here
> %br Line three goes here
>
> ... then it *kinda* works, but it's rendering like this: "<br>Line two
> goes here</br>" ... which is totally bogus.
>
> I can put
> .fooclass
> Line one
> %br/
> Line Two
> %br/
> Line Three
>
> ... but I'd hardly call that Markup Haiku!!

First of all: Don't worry on where the <br/> appears on the rendered
HTML. It will work fine.

Second: <br/> is one of several "strange" tags which are meant to be
empty - that's what the final '/' means in XML: Don't expect a closing
tag for this.

You can, as suggested, include the '<br/>' as part of your text - but
I agree, that's not what I have in mind when using HAML. But:

.fooclass
Line one
%br
Line two
%br
Line three

renders:

<div class='fooclass'>
Line one
<br />
Line two
<br />
Line three
</div>

Greetings,

Reply all
Reply to author
Forward
0 new messages