玉模板引擎(在node.js下):多行块,不带管道符号 [英] jade template engine (under node.js): multi-line block without pipe symbol

查看:73
本文介绍了玉模板引擎(在node.js下):多行块,不带管道符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在一个新项目上使用Jade.似乎很适合组成Web应用程序布局,但不适用于编写静态内容,例如包含文本的

元素的网页.

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?

我正在研究的一种解决方案是创建:block过滤器或类似的东西,该过滤器在每行前都添加| |.然后将其传递给Jade,但至少可以说jade关于创建过滤器的文档很少,因此可能要花一些时间才能弄清楚.如果有人可以提供有关这种解决方案的指导,我将不胜感激.

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.

推荐答案

来自玉器github页面:

p.
foo asdf
asdf
 asdfasdfaf
 asdf
asd.

产生输出:

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

p之后的尾随时间段是您要查找的内容.

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

这篇关于玉模板引擎(在node.js下):多行块,不带管道符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆