【问题标题】:Run a Liquid filter from a Jekyll plugin从 Jekyll 插件运行 Liquid 过滤器
【发布时间】:2013-09-29 04:09:13
【问题描述】:

Liquid 有两个过滤器,名为 newline_to_brescape

我正在开发一个需要通过这些过滤器运行字符串的 Jekyll 插件。与其安装一个单独的 gem 来执行此操作,或者为它编写我自己的代码,有没有办法直接从插件内部调用这些过滤器?

【问题讨论】:

    标签: ruby jekyll liquid


    【解决方案1】:

    这些过滤器可以通过include Liquid::StandardFilters 线获得。

    例如:

    class PlaintextConverter
        include Liquid::StandardFilters
        def convert(content)
            content = escape(content)
            content = newline_to_br(content)
            content
        end
    end
    

    有关以这种方式可用的功能的完整列表,您可以查看the source of standardfilters.rb

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-11
      • 1970-01-01
      • 2014-10-20
      • 2017-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多