Sha256: 99154a9c4225911e6491c6452640f078fb6eb7381e16882e9412c052dba5cf1d

Contents?: true

Size: 974 Bytes

Versions: 4

Compression:

Stored size: 974 Bytes

Contents

# -*- encoding: utf-8 -*-

module Genit

  # Replace the <genit class="menu"/> in the template.
  class ClassMenuTag < Tag
  
    # Public: Constructor.
    #
    # working_dir - The String working directory, where live the project.
    # template    - The Nokogiri::XML::Document into which we process the tag.
    # filename    - The String name of the page
    # tag         - The tag to process as a Nokogiri::XML::Element
    def initialize working_dir, template, filename, tag
      super working_dir, template, filename, tag
    end
    
    # Public: Do the replacement.
    #
    # Returns the template as a Nokogiri::XML::Document
    def process
      build_menu
      replace_tag_into_template! 'genit.menu', @menu.to_html
    end
    
    private
    
    def build_menu
      menu = XmlDocument.open(File.join(@working_dir, "templates/menu.html"))
      builder = MenuBuilder.new(menu)
      @menu = builder.build_for_page(@filename)
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
genit-1.0.1 lib/genit/tags/class_menu_tag.rb
genit-1.0 lib/genit/tags/class_menu_tag.rb
genit-0.99 lib/genit/tags/class_menu_tag.rb
genit-0.9 lib/genit/tags/class_menu_tag.rb