Amit Kumar Gupta
Amit Kumar Gupta

Reputation: 7413

Jekyll Liquid Exception for Unknown custom tag

I have created a following custom Jekyll liquid tag

# 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)

And I'm using it in following way in a markdown post

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

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

Upvotes: 0

Views: 265

Answers (1)

Amit Kumar Gupta
Amit Kumar Gupta

Reputation: 7413

I got to know that a tag can't have data within. So I had to replace Liquid::Tag with Liquid::Block to solve the issue

Upvotes: 0

Related Questions