0

I need to output plain text in a jade layout (using express) and I need it to appear on separate lines like so -

Hello
There
World"0"
World"1"
World"2"

I would have thought I could do it like this - (jade template coming up)

|Hello
|There
- for (var i=0; i<3; i++)
  |World"#{i}"

But instead this gives me

Hello
ThereWorld"0"World"1"World"2"

For the life of me, I cannot understand how to do a line break within a conditional loop! This is not meant to be HTML text, its plain text for CSV binary output, so the breaks are important and so are the double quotes as well as the escaping to prevent tags.

Is it not possible to do this in Jade? I don't have much experience in Jade, so I'd appreciate any help at all from the experts out there. Thanks!

4

2 回答 2

0

我已经更新了 OP 以包含动态变量和双引号,这是我真正需要的东西。

玩弄了@Amberlamps 的建议并想出了这个答案-

|Hello
|There
- for (var i=0; i<3; i++)
  ="\n"
  |World"#{i}"

我确信这个解决方案还有其他变体,但这个对我有用。

如果我需要做更高级的模板,我肯定会检查 Mustache 或 Handlebars - Jade 及其文档只是不适合我。

于 2012-08-06T08:25:11.527 回答
0

Try this:

- for(var i = 0; i < 3; i++)
    = World + "\n"
于 2012-08-05T16:49:01.027 回答