【发布时间】:2016-01-10 14:52:43
【问题描述】:
我正在使用layout taglib 将页面扩展到其模板,但我不知道如何将变量传递给主布局并应用条件类。
考虑到这是我的main-layout.marko
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body class="#### (TITLE === 'REGISTER')?'ACTIVE':'INACTIVE' ####">
<layout-placeholder name="title"/>
<layout-placeholder name="body"/>
</body>
</html>
这是我的registration.marko
<layout-use template="./layout.marko">
<layout-put into="title">
$data.title
</layout-put>
<layout-put into="body">
some content
</layout-put>
</layout-use>
最后这是我用来渲染页面并传递标题数据的代码
router.get('/register', function(req, res, next) {
registration.render({
title: 'register'
}, res);
});
如何在 main-layout.marko 文件上创建一个条件类,根据页面标题在 active 或 inactive 之间切换?
谢谢
【问题讨论】:
标签: node.js template-engine marko