Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liquid error: wrong number of arguments

I am trying a simple Jekyll plugin:

class MonthlyArchives < Liquid::Tag

    def initialize(tag_name, text, tokens)
      super
      @text = text
    end

    def render(context)
      "#{@text} #{Time.now}"
    end

end

Liquid::Template.register_tag('monthly_archives1', Jekyll::MonthlyArchives)

When I try to run it in page as follows:

{% monthly_archives1 %}

I get Liquid error: wrong number of arguments (2 for 0). Any ideas ?

like image 741
Madhur Ahuja Avatar asked Nov 04 '22 19:11

Madhur Ahuja


1 Answers

I haven't had any chance to build something with Liquid, but the Jekyll wiki page about building your own plugins has the whole class surrounded with module before registering that

module Jekyll
    ...your code...
end

Liquid::Template.register_tag('monthly_archives1', Jekyll::MonthlyArchives)

that might be an issue.

like image 64
c00kiemon5ter Avatar answered Nov 15 '22 07:11

c00kiemon5ter