我正在重构我的页面以获得动态包含,在服务器上预呈现它们,并将它们传递给res.render()
但是现在,页面上出现了<
和>
,并且包含了两次,我无法理解。
routes/tips.js
// ...
router.get('/addition/:number', function(req, res) {
console.dir(renderTemplate(makePath('add/add' + req.params.number))); // shows just what i want, without extra characters
res.render('tips/tipsLayout', {content: renderTemplate(makePath('add/add' + req.params.number))});
// at this point, 'content' is definitely correct.
});
// ...
tipsLayout.jade
extends ../layout
block content
.wrapper.col-xs-12.col-md-12.col-lg-10.col-lg-offset-1
h1= title
a(href='/tips/', data-i18n="buttons.back")
p(data-i18n="markup.tipsHeading")
block extraJS
script(src='/javascripts/tips.js', type='text/javascript')
include tipsMenu.jade
.tipContent
#{content} // here i want to insert pre-rendered 'content'
tips/add/add0.jade
(这是预渲染的内容)
- var path = "[html]hints.+.0."
h1(data-i18n=path + "0")
.tipsFrame
.tipsText
p(data-i18n=path + "1")
p(data-i18n=path + "2")
p(data-i18n=path + "3")
.tipsExample
p(data-i18n=path + "4")
p(data-i18n=path + "5")
p(data-i18n=path + "6")
html输出:
// ...
<div class="tipContent"> // so it looks like it is something inside 'content' after all..?
"<"
<h1 data-18n="[html]hints.+.0.0">Addition from left to right (1)</h1>
<div class="tipsFrame">...</div>
">"
<!--<h1 data-i18n="[html]hints.+.0.0"--> // note the comment here...(where does that come from?)
<div class="tipsFrame">...</div>
">"
</div>
// ...
之前一切正常,提示正常包含extend
/ block
s
我想也许它与block content
和#{content}
具有相同的名称有关,但我改变了后者并且仍然是相同的输出。
啊好......看起来#{content}
必须是!{content}
....
答案 0 :(得分:1)
计算它..
#{content}
=&gt; !{content}
...