在哪里访问和存储EJS助手-SailsJS [英] Where to access and store EJS Helpers - SailsJS

查看:55
本文介绍了在哪里访问和存储EJS助手-SailsJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧

SailJS的默认模板引擎是 EJS 嵌入式Javascript

SailJS's default templateing engine is EJS (Embedded Javascript)

但是我似乎找不到可以创建自己的帮助者和东西的地方。

But I cannot seem to find the place where we can create our own helpers and stuff.

所以,您知道从哪里访问&存储 EJS 助手/东西?

So, do you know where to access & store EJS helpers/stuff?

推荐答案

已解决:
https://github.com/balderdashy/sails/issues/2162#issuecomment-55866731

config / http.js

config/http.js

module.exports.http = {
  // ...
  locals: {
    filters: {
      formatDate: function(date) { }
    }
  }
}

config / bootstrap.js

config/bootstrap.js

_.extend(sails.hooks.http.app.locals, sails.config.http.locals);

从某些角度看...

views / test.ejs

views/test.ejs

<%=: created | formatDate %>

这篇关于在哪里访问和存储EJS助手-SailsJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆