liquid.js icon indicating copy to clipboard operation
liquid.js copied to clipboard

Use liquid filter in JavaScript

Open maxfrigge opened this issue 10 years ago • 2 comments

Is there a way to apply a filter outside of a template? There are certain occasions where this could be useful.

var result = Liquid.applyFilter(myVar, "capitalize");

maxfrigge avatar Jun 24 '15 19:06 maxfrigge

Haven't tested this, but in theory you should be able to do this:

Liquid.Strainer.filters.capitalize( myVar )

A more official API for accessing those might be nice.

mattmccray avatar Jun 25 '15 16:06 mattmccray

It works... thanks!

maxfrigge avatar Jun 26 '15 14:06 maxfrigge