ejs icon indicating copy to clipboard operation
ejs copied to clipboard

a filters mistake?

Open purplebamboo opened this issue 8 years ago • 3 comments

when i use the filters, i find something wrong。 in the line: https://github.com/tj/ejs/blob/master/lib/ejs.js#L57

function filtered(js) {
  return js.substr(1).split('|').reduce(function(js, filter){
    var parts = filter.split(':')
      , name = parts.shift()
      , args = parts.join(':') || '';   //this must  be ',' , am i right ?
    if (args) args = ', ' + args;
    return 'filters.' + name + '(' + js + args + ')';
  });
};

my code like this:

<%=: test | filter:'111':'222' %>

purplebamboo avatar Aug 13 '15 09:08 purplebamboo

This version of EJS is no longer supported. The current version (installable with NPM) is here: https://github.com/mde/ejs

mde avatar Aug 13 '15 17:08 mde

but v2 has remove the filters。 in my project i still use the filters, can you fix this bug in the old version。

purplebamboo avatar Aug 14 '15 02:08 purplebamboo

The filters were removed because they're not core to what EJS does. Your best bet is to pre-process your data before handing it to your templates.

mde avatar Aug 14 '15 05:08 mde