mah*_*off 115 markup node.js pug
我正在尝试用Jade创作几段,但是当段落中有链接时发现很难.
我能想出的最好的,我想知道是否有办法用更少的标记来做到这一点:
p
span.
this is the start
of the para.
a(href="http://example.com") a link
span.
and this is the rest of
the paragraph.
Run Code Online (Sandbox Code Playgroud)
Cla*_*ick 113
从jade 1.0开始,有一种更简单的方法可以解决这个问题,遗憾的是我无法在官方文档中的任何地方找到它.
您可以使用以下语法添加内联元素:
#[a.someClass A Link!]
Run Code Online (Sandbox Code Playgroud)
因此,在ap中不进入多行的示例将是:
p: #[span this is the start of the para] #[a(href="http://example.com") a link] #[span and this is the rest of the paragraph]
Run Code Online (Sandbox Code Playgroud)
您还可以执行嵌套的内联元素:
p: This is a #[a(href="#") link with a nested #[span element]]
Run Code Online (Sandbox Code Playgroud)
Dan*_*lig 93
您可以使用降价过滤器并使用markdown(和允许的HTML)来编写段落.
:markdown
this is the start of the para.
[a link](http://example.com)
and this is the rest of the paragraph.
Run Code Online (Sandbox Code Playgroud)
或者,您似乎可以简单地输出HTML而不会出现任何问题:
p
| this is the start of the para.
| <a href="http://example.com">a link</a>
| and this is he rest of the paragraph
Run Code Online (Sandbox Code Playgroud)
我自己并没有意识到这一点,只是使用jade命令行工具对其进行了测试.它似乎工作得很好.
编辑: 看来它实际上可以完全在Jade中完成,如下所示:
p
| this is the start of the para
a(href='http://example.com;) a link
| and this is the rest of the paragraph
Run Code Online (Sandbox Code Playgroud)
不要忘记para末尾有一个额外的空间(虽然你看不到它.之间| and.否则看起来para.a linkand不会这样para a link and
per*_*era 45
另一种方法:
p
| this is the start of the para
a(href="http://example.com") a link
| this is he rest of the paragraph.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
67434 次 |
| 最近记录: |