你好,我正在尝试使用Jade的块和扩展来完成一个node.js项目,我的想法是创建如下内容:
layout.jade:
head
script
$(document).ready(function() {
block js_doc_ready
//here goes the doc ready
});
index.jade:
block js_doc_ready
alert('hello!');
alert('one more js line code');
alert('end my js doc ready for this view');
这将给我一个类似于以下的 index.html 文件:
...
<head>
<script type="text/javascript">
$(document).ready(function() {
alert('hello!');
alert('one more js line code');
alert('end my js doc ready for this view');
});
</script>
</head>
...
但是当我看到结果时,'block js_doc_ready'并没有被视为Jade块。 此外,即使它被视为块,"alert('hello!);'也不会被视为Jade标签,而是作为普通文本处理。
这是我以前在django模板中做的事情,但在jade中,由于有太多的标签可用,且不能自由地使用纯html,所以我仍然觉得这些东西有点奇怪。
title Hello jade !="
但这种方法看起来有点麻烦... 我能否在不使用 | 的情况下拥有多行字符串? - Arruda