无法解释的“<”和玉的双倍输出包括

时间:2016-01-11 13:07:39

标签: javascript node.js express include pug

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

this is how it looks

更新

我想也许它与block content#{content}具有相同的名称有关,但我改变了后者并且仍然是相同的输出。

更新2&amp;溶液

啊好......看起来#{content}必须是!{content} ....

1 个答案:

答案 0 :(得分:1)

计算它..

#{content} =&gt; !{content} ...

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