Reputation: 8468
Liquid has two filters named newline_to_br
and escape
.
I'm working on a Jekyll plugin that needs to run a string through those filters. Rather than install a separate gem which does this, or write my own code for it, is there any way to call those filters directly from inside of the plugin?
Upvotes: 3
Views: 573
Reputation: 8468
Those filters can become available with the line include Liquid::StandardFilters
.
For example:
class PlaintextConverter
include Liquid::StandardFilters
def convert(content)
content = escape(content)
content = newline_to_br(content)
content
end
end
For a full list of functions that become available in this way, you can view the source of standardfilters.rb
Upvotes: 5