【发布时间】:2018-03-30 07:47:30
【问题描述】:
我正在尝试通过快速路由向仅包含一个 mixin 的 pug 文件提供上下文。但是当我尝试渲染该文件时,它什么也不做。
This is my express route
app.post('/comment', (req, res) => {
const test = {
text: 'working',
};
res.render('comment-section', test);
});
这是我的 pug 文件 mixin
mixin comment()
div.comment-content
div.row
div.col-lg-1
a(href="#")
img(src="img/default_profile.jpg").comment-profile-img
div.col-lg-10
p.user-comment
| Comment //- <--- Here i would like to use the test object this way {#text}
div
textarea(name="post_content" placeholder="Comment something" rows="1").comment-textarea.post-comment-message
如何让 pug mixin 从路由中获取上下文(测试对象)并使用它。 提前致谢!
【问题讨论】:
标签: express pug viewengine