Class: Jekyll::AttendeasePlugin::PortalNavigationTag

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) ⇒ PortalNavigationTag

Returns a new instance of PortalNavigationTag.



86
87
88
89
90
91
92
93
# File 'lib/jekyll/attendease_plugin/tags.rb', line 86

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



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/jekyll/attendease_plugin/tags.rb', line 95

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

  nav = []
  if portal_pages.is_a?(Array)
    portal_pages.sort! { |a, b| a['weight'] <=> b['weight'] }
    portal_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