Class: Jekyll::AttendeasePlugin::NavigationTag

Inherits:
Liquid::Block
  • Object
show all
Defined in:
lib/jekyll/attendease_plugin/tags.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, params, tokens) ⇒ NavigationTag

Returns a new instance of NavigationTag.



116
117
118
119
120
121
122
123
# File 'lib/jekyll/attendease_plugin/tags.rb', line 116

def initialize(tag_name, params, tokens)
  super
  @options = {}
  params.split(/\s/).each do |keypair|
    opt = keypair.split('=')
    @options[opt[0]] = opt[1] if opt.length == 2
  end
end

Instance Method Details

#render(context) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/jekyll/attendease_plugin/tags.rb', line 125

def render(context)
  pages = context.registers[:site].data['pages']

  nav = []
  if pages.is_a?(Array)
    pages.sort! { |a, b| a['weight'] <=> b['weight'] }
    pages.select { |p| p['top_level'] }.each do |page|
      if page['active'] && !page['hidden']
        template = Liquid::Template.parse(super)
        template.assigns['page'] = page
        nav << template.render
      end
    end
    nav.join("\n")
  else
    ''
  end
end