Adding a Filter to EJS in Node.ACS

You must Login before you can answer or comment on any questions.


I have a node application(that uses Express, Jade and Mongoose) that I have successfully ported to use Node.ACS but using EJS instead of JADE (at least running locally at the moment within TiStudio)

My question is that I would like to add a custom filter to EJS (see here ) but cannot find a way to do it. Does anyone know if it it possible using Node.ACS to extend EJS in this way?


1 Answer

Accepted Answer

Hi Steve,

Could you please try this in app.js:

var ejs = require('ejs');
ejs.filters.myfilter = function() {
  //do something

— answered 3 years ago by Bill Wang
answer permalink
  • So I tried this already and got nowhere......

    but it's funny when someone else suggests it and you go back and look at your code I had forgotten to use the : in the ejs file

    i.e. I had

    <%= content.title | myFilter %>

    and it should have been

    <%=: content.title | myFilter %>

    works great

    — commented 3 years ago by Steve Rogers

  • Nice!

    — commented 3 years ago by Bill Wang

Your Answer

Think you can help? Login to answer this question!