Run the liquid filter from the Jekyll plugin

The fluid has two filters with the name newline_to_brand escape.

I am working on a Jekyll plugin that should run a string through these filters. Instead of installing a separate stone that does this, or writing custom code for it, is there a way to call these filters directly from within the plugin?

+1
source share
1 answer

These filters can be accessed using the string 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 complete list of features that become available in this way, you can view the sourcestandardfilters.rb

+1
source

Source: https://habr.com/ru/post/1527144/


All Articles