link_to和其他不包含在EJB(与Express)捆绑在一起)Node.js的视图助手? [英] link_to and other view helpers not included with EJS (bundled with Express) for Node.js?
本文介绍了link_to和其他不包含在EJB(与Express)捆绑在一起)Node.js的视图助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用Express Web框架设置了一个nodeJS服务器,使用EJS模板引擎。
I've set up a nodeJS server using the Express web framework, using the EJS template engine.
当我尝试使用EJS link_to
在视图中查看帮助器,我得到一个引用错误。这是因为我做错了事情,还是看不到帮助者?
When I try to use the EJS link_to
view helper inside a view, I get a reference error. Is this because I am doing something wrong, or are the view helpers just not included?
我尝试了以下
<# link_to("...", "...") #>
<#= link_to("...", "...") #>
<#- link_to("...", "...") #>
注意:我为EJS ...配置了自定义标签...
server.configure(function ()
{
this.set("view engine", "ejs");
this.set("view options", { open: "<#", close: "#>" });
});
推荐答案
尝试:
var helpers = require('express-helpers')
然后
helpers(app);
在你的app.js
如果仍然不工作,尝试
<% - link_to
而不是<%= link_to
in your app.js
if still not working, try
<%- link_to
instead of <%= link_to
这篇关于link_to和其他不包含在EJB(与Express)捆绑在一起)Node.js的视图助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文