未知自定义标签的 Jekyll Liquid 异常

问题描述 投票:0回答:0

我创建了以下自定义 Jekyll 液体标签

# my_tag.rb
module Jekyll
    class MyTag < Liquid::Tag
      def initialize(tag_name, markup, tokens)
        super
        @title = markup['title']
        @step = markup['step']
      end

      def render(context)
        output = "<div>"
        output += "<h1>#{@title} #{@step}</h1>"
        output += "<p>#{super}</p>"
        output += "</div>"
        output
      end
    end
end

Liquid::Template.register_tag('my_tag', Jekyll::MyTag)

我在降价帖子中按照以下方式使用它

{% my_tag title="hello" step="world" %}
This is the data
{% endmy_tag %}

但它给出了错误

Liquid Exception: Liquid syntax error (line 351): Unknown tag 'endmy_tag'

jekyll liquid
© www.soinside.com 2019 - 2024. All rights reserved.