5

Input:

.a text1
.b text2

Output will be:

<div class="a">text1</div><div class="b">text2</div>

The second <div> is just close to the first one without any spaces or LFs.

However, this is what I really want to get:

<div class="a">text1</div>
<div class="b">text2</div>

or:

<div class="a">text1</div> <div class="b">text2</div>

Because I need to put a space between them when I use display:inline-block. I don't want to set the margin in CSS.

Is it possible to let jade not eat my spaces or LFs?

Thanks,

Reza Owliaei
  • 3,293
  • 7
  • 35
  • 55
AGamePlayer
  • 7,404
  • 19
  • 62
  • 119

1 Answers1

4

This block of code

.a text1
| &sp;
.b text2

compile to

<div class="a">text1</div>
&sp;
<div class="b">text2</div>

&sp; is the medium space (http://www.w3.org/)

Update: or use this code

- var space = ' '
.a text1
| #{space}
.b text2
madmxg
  • 359
  • 2
  • 9
  • 2
    I downvoted this answer, because it actually was not entirely correct. You should not use `&sp;`, as it is not exactly the same as a regular space character. The more correct approach is described here: http://stackoverflow.com/a/22220139/339176. TL;DR: use ` ` if you want a non breaking space, OR use ` ` (or ` ` in hex) to get the real space. ` ` is what I use in my code and it works great. – piotr.d May 28 '15 at 13:19
  • `| #{' '}` I have to write down the full answer comment. It works!. Thanks. – Han May 31 '15 at 12:38