Casey Flynn
Casey Flynn

Reputation: 14048

jade template ignoring first space on line after pipe symbol

I have a minor detail question regarding jade templates

I'm seeing the following template:

p(data-ng-show="submitting")
 i.icon-cog.icon-spin
 | Authenticating...

being converted to this HTML

<p data-ng-show="submitting"><i class="icon-cog icon-spin"></i>Authenticating...</p>

Note the single space before "Authenticating..." is not carried over into the compiled HTML. Is the only solution here to use   to force a white space?

Upvotes: 3

Views: 2313

Answers (2)

gustavohenke
gustavohenke

Reputation: 41440

That's how Jade is supposed to work, and I know, it's veeery bad having to deal with such a thing.

You can do this:

p(data-ng-show="submitting")
 i.icon-cog.icon-spin
 |  Authenticating...

which I think is somewhat tricky.

Another option is to print an whitespace HTML entity, as already suggested by @brnrd:

p(data-ng-show="submitting")
  i.icon-cog.icon-spin
  | &nbsp;Authenticating...

Yet another option, but very bad in my opinion (or not that much if you use i18n), is:

p(data-ng-show="submitting")
  i.icon-cog.icon-spin
  = " Authenticating..."

Upvotes: 6

brnrd
brnrd

Reputation: 3486

Just add a white space character :

&nbsp;

As :

p(data-ng-show="submitting")
  i.icon-cog.icon-spin
  | &nbsp;Authenticating...

It does the trick.

Upvotes: 2

Related Questions