Sha256: 3ba372f9365f74c1e2e3d01256cc7501cd472b6c8ae7f34d97896cef67c579d5

Contents?: true

Size: 693 Bytes

Versions: 3

Compression:

Stored size: 693 Bytes

Contents

class ComfyPress::Tag::Menu
  include ComfyPress::Tag

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

  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

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

Version data entries

3 entries across 2 versions & 1 rubygems

Version Path
comfypress-0.1.4 db/lib/comfypress/tags/menu.rb
comfypress-0.1.4 lib/comfypress/tags/menu.rb
comfypress-0.1.3 lib/comfypress/tags/menu.rb