jade template engine (under node.js): multi-line block without pipe symbol

Jake picture Jake · Jan 17, 2011 · Viewed 17.2k times · Source

I'm currently using Jade on a new project. It seems well-suited to composing webapp layouts, but not for writing static content, such as a web page of

elements containing text.

For example, to create such a paragraph, I believe I need to do this:

p
  | This is my long,
  | multi-line
  | paragraph.

For a static web page full of real paragraphs of text, using jade becomes a burden due to that pipe symbol at the beginning of each line.

Is there some sort of syntactic sugar for marking the whole block as a text node, as the pipe symbol does on a line-by-line basis? Or an existing filter I'm unaware of?

One solution I'm exploring is the creation of a :block filter or something, that prepends each line with a | and then passes it to Jade, but jade's documentation on creating filters is sparse to say the least, so that may take a while to figure out. If anyone can provide guidance as to such a solution I'd appreciate it.

Answer

Doughsay picture Doughsay · Apr 28, 2011

From the jade github page:

p.
foo asdf
asdf
 asdfasdfaf
 asdf
asd.

produces output:

<p>foo asdf
asdf
  asdfasdfaf
  asdf
asd
.
</p>

The trailing period after the p is what you're looking for.