Where to access and store EJS Helpers - SailsJS

前端 未结 3 647
攒了一身酷
攒了一身酷 2021-01-13 08:44

Well,

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

But I cannot seem to find the place where we can create ou

3条回答
  •  执念已碎
    2021-01-13 09:25

    solved: https://github.com/balderdashy/sails/issues/2162#issuecomment-55866731

    config/http.js

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

    config/bootstrap.js

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

    At some view...

    views/test.ejs

    <%=: created | formatDate %>
    

提交回复
热议问题