Class: JekyllBlocker::MenuTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-blocker/tags/menu_tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, params, parse_context) ⇒ MenuTag

Returns a new instance of MenuTag.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/jekyll-blocker/tags/menu_tag.rb', line 3

def initialize(tag_name, params, parse_context)
  super
  parts = params.to_s.strip.split.compact

  if parts.count == 2
    @name  = parts.first.strip
    @style = parts.last.strip
  else
    raise Liquid::SyntaxError, "menu tag expects 2 arguments, #{parts.count} given"
  end
end

Instance Method Details

#render(context) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jekyll-blocker/tags/menu_tag.rb', line 15

def render(context)
  @context = context
  @style   = parse_param(@style)
  menu     = build_menu(load_menu(@name))

  if style_wrapper
    menu = render_part(style_wrapper, { "content" => menu })
  end

  menu
end