Class: CustomTags::MenuGenerator
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- CustomTags::MenuGenerator
- Defined in:
- lib/custom_tags.rb
Instance Method Summary (collapse)
- - (Object) create_child(object)
-
- (MenuGenerator) initialize(tag_name, markup, tokens)
constructor
A new instance of MenuGenerator.
- - (Object) menu_generator(args)
- - (Object) render(context)
Constructor Details
- (MenuGenerator) initialize(tag_name, markup, tokens)
A new instance of MenuGenerator
44 45 46 47 48 |
# File 'lib/custom_tags.rb', line 44 def initialize(tag_name, markup, tokens ) super @tag_name = tag_name @args = eval('{'+ markup +'}') end |
Instance Method Details
- (Object) create_child(object)
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/custom_tags.rb', line 69 def create_child(object) str = "" str = '<ul id="' + object.name + '">' object.children.each do |child| str += "<li><a href=#{child.title_sanitized.to_s == '' ? '#' : '/' + child.title_sanitized}>#{child.name}</a>" #str += "<li>#{link_to child.name, (child.title_sanitized.to_s == '' ? '#' : '/' + child.title_sanitized)}" str += child.children.blank? ? '</li>' : create_child(child) + '</li>' end str += '</ul>' end |
- (Object) menu_generator(args)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/custom_tags.rb', line 54 def (args) str = "" @menus = $current_website.. ul = args[:ul] ? "<ul id=#{args[:ul]} class=#{args[:ul]}>" : '<ul>' li = args[:li] ? "<li id=#{args[:li]} class=#{args[:li]}>" : '<li>' current = args[:current] ? "<li id=#{args[:current]} class=#{args[:current]}>" : '<li>' str += ul @menus.roots.each do |root| str += li + "<a href=#{root.title_sanitized.to_s == '' ? '#' : '/' + root.title_sanitized}>#{root.name}</a>" #str += li + "#{link_to root.name, (root.title_sanitized.to_s == '' ? '#' : '/' + root.title_sanitized) }" str += root.children.blank? ? '</li>' : create_child(root) + '</li>' end str += '</ul>' end |
- (Object) render(context)
50 51 52 |
# File 'lib/custom_tags.rb', line 50 def render(context) (@args) end |