Jade Interpolation#{} vs Buffered =' '

时间:2014-10-26 00:58:25

标签: node.js pug

从控制器注入数据时

module.exports.index = function(req, res) {
    res.render('index', { title: 'HelloWorld' } );
};

进入Jade模板,我可以做缓冲

h1= title

或插值

#{ title }

两者似乎做同样的事情,但有两个不同的名称和语法。我知道这可能是微不足道的,但我无法找出两者之间的区别。有什么区别?

1 个答案:

答案 0 :(得分:0)

使用#{title}也用于连接信息

h1 This is my title #{title}, well is look cool!!

并使用=title来插入变量的内容而不连接

h1= title

第一个更容易连接字符串。