ejs发送变量到partial
搜遍了SO、google和EJS网站,找不到任何东西。如果您有文档链接,请分享。
我有一个名为 rooms.ejs 的视图,我以这种方式加载它:
app.get('/rooms', function(req, res){
RoomProvider.findAll(function(error, rooms){
res.render('rooms', {
locals: {
title: 'List of rooms',
rooms: rooms
},
layout:'simple'
});
});
});
这就是我在该视图 (rooms.ejs) 中的内容: <%-partial('room', rooms) %>
部分打印 <%= room.owner %>
。效果很好。
我尝试将部分重命名为 rooms_partial,但现在我不知道通过 <%= room.owner %>
发送的变量名称不再有效,<代码><%= rooms_partial.owner %>
Scoured SO and google and the EJS site, couldn't find anything. If you have links to docs, please share.
I have a view called rooms.ejs and I load it this way:
app.get('/rooms', function(req, res){
RoomProvider.findAll(function(error, rooms){
res.render('rooms', {
locals: {
title: 'List of rooms',
rooms: rooms
},
layout:'simple'
});
});
});
This is what I have inside that view (rooms.ejs): <%- partial('room', rooms) %>
The partial prints <%= room.owner %>
. Works well.
I tried to rename the partial to rooms_partial, but now I have no idea what variable names get sent over <%= room.owner %>
no longer works, <%= rooms_partial.owner %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TJ 的回答是这样的:
TJ answered w/ this: