Class: ComfyPress::Tag::Menu

Inherits:
Object
  • Object
show all
Includes:
ComfyPress::Tag
Defined in:
lib/comfypress/tags/menu.rb

Constant Summary

Constants included from ComfyPress::Tag

IDENTIFIER_REGEX, TOKENIZER_REGEX

Instance Attribute Summary

Attributes included from ComfyPress::Tag

#identifier, #namespace, #page, #params, #parent

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.regex_tag_signature(identifier = nil) ⇒ Object



4
5
6
7
8
9
# File 'lib/comfypress/tags/menu.rb', line 4

def self.regex_tag_signature(identifier = nil)
  # identifier ||= /[\w\-]+/
  # /\{\{\s*cms:menu:(#{identifier})\s*\}\}/
  identifier ||= /[\w\/\-]+/
  /\{\{\s*cms:menu:(#{identifier}):?(.*?)\s*\}\}/
end

Instance Method Details

#contentObject



11
12
13
14
15
16
17
# File 'lib/comfypress/tags/menu.rb', line 11

def content
  # Find or initialize Cms::Menu object
  menu = page.site.menus.detect{|s| s.identifier == self.identifier.to_s}
  if menu
    "<%= render partial: 'cms_content/menu', locals: {menu_id: #{menu.id}} %>"
  end
end

#renderObject



19
20
21
22
23
24
25
26
# File 'lib/comfypress/tags/menu.rb', line 19

def render
  whitelist = ComfyPress.config.allowed_partials
  if whitelist.is_a?(Array)
    content if whitelist.member?(identifier)
  else
    content
  end
end