gpt4 book ai didi

javascript - jade 中无法解释的 "<"和双输出包括

转载 作者:行者123 更新时间:2023-11-30 00:15:58 26 4
gpt4 key购买 nike

我正在重构我的页面以具有动态包含,在服务器上预呈现它们,并将它们传递给 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.
});

// ...

this is 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

this is how it looks

更新

我在想这可能与 block content 有关和 #{content}具有相同的名称,但我更改了后者并且仍然是相同的输出。

更新2 & 解决方案

嗯..看起来像#{content}必须是 !{content} ....

最佳答案

开始吧..

#{content} => !{content} ...

突然之间,所有的错误都消失了

关于javascript - jade 中无法解释的 "<"和双输出包括,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34722354/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com