如何在ejs / express的全局variables中使用函数?
var app = express(); app.locals.current_time = utils.current_time();
我可以为模板中的每个请求更改此variables的variablescurrent_time吗? 这个例子中的app.locals.current_time是常量,但我想使用函数。
app.locals.current_time = function () { return utils.current_time(); };
那么在ejs模板上就像这样使用它:
<%= current_time() %>
- 在脚本运行完成后允许点击链接
- node.js和jade:显示来自属性值的内容 – 不显示的行
- node.js i18n .__不是一个函数
- testingREST API – req.body undefined(Node.js / Express / Mocha / Supertest)
- Node.js和Express:如何在asynchronous操作之后返回响应
- REST API:在GUI中无限滚动分页,但允许search所有条目
- Nodejs用户configuration文件和会话
- 如何在Locomotivejs中设置coffescript?
- 使用NodeJS,Express和Passport-ldapauth进行LDAP身份validation