Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a whitespace at the end of the line in Jade

I have this jade code:

p     | Avatar hosted by     a(href='http://www.gravatar.com/', target='_blank') Gravatar 

The problem is, it's rendered to

<p>Avatar hosted by<a href="http://www.gravatar.com/" target="_blank">Gravatar</a></p> 

Which looks like: "Avatar hosted byGravatar".

No matter how many spaces I added at the end of the text line, it still looks like this. The Docs couldn't help me, and I can't imagine this to be such an uncommon problem.

like image 562
Lanbo Avatar asked May 09 '12 12:05

Lanbo


2 Answers

If you don't want inline HTML or HTML entities in your code this is what you can do:

p     | Avatar hosted by     =  ' '     a(href='http://www.gravatar.com/', target='_blank') Gravatar 

or this is is shorter

p= 'Avatar hosted by '     a(href='http://www.gravatar.com/', target='_blank') Gravatar 

The cleanest is probably this

p Avatar hosted by #{''}     a(href='http://www.gravatar.com/', target='_blank') Gravatar 
like image 102
iopq Avatar answered Sep 29 '22 12:09

iopq


Which version of jade are you using? I just tested (with 0.25.0) with a single space following 'by', and it worked correctly.

Other options are:

p     | Avatar hosted by&nbsp;     a(href='http://www.gravatar.com/', target='_blank') Gravatar 

or

p     | Avatar hosted by     |  <a href='http://www.gravatar.com/' target='_blank'>Gravatar</a> 
like image 26
jmar777 Avatar answered Sep 29 '22 11:09

jmar777