我想专注于学习如何在 Node 中构建东西,而不必摆弄 Jade 语法。我想知道是否可以将本地 html 语法与其循环语法等混合在 jade 模板中。如果可以,如何混合。如果没有,是否有 Node 模板引擎允许这样做。
谢谢。
最佳答案
为了确保您可以混合纯 HTML 和 Jade 代码,只需使用 Piped Text .
例如:
| <a href="#">Plain HTML</a>
这里是 Jade Online Demo 的示例(实际上很高兴尝试和测试某些东西!):
doctype html
html(lang="en")
head
title= pageTitle
script(type='text/javascript').
if (foo) {
bar(1 + 5)
}
body
h1 Jade - node template engine
#container.col
if youAreUsingJade
p You are amazing
else
p Get on it!
p.
Jade is a terse and simple
templating language with a
strong focus on performance
and powerful features.
| <a href="#">Plain HTML</a>
使用此测试数据:
{
pageTitle: 'Jade Demo',
youAreUsingJade: true
}
生成此代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jade Demo</title>
<script type="text/javascript">
if (foo) {
bar(1 + 5)
}
</script>
</head>
<body>
<h1>Jade - node template engine</h1>
<div id="container" class="col">
<p>You are amazing</p>
<p>
Jade is a terse and simple
templating language with a
strong focus on performance
and powerful features.
</p>
</div><a href="#">Plain HTML</a>
</body>
</html>
关于node.js - 如何在jade模板中使用HTML语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22661034/