Sha256: 6344eeab030437f37ae3abbf3312cc33cd956cfc1620f934f6ac16193d1d230b

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

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

module Genit

  # A Genit general tag.
  # Currently we have three tags:
  #   * <genit class="pages"/>
  #   * <genit class="menu"/>
  #   * <genit class="fragment" file="foo.html"/>
  class ClassTag < 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: Replace something in the template.
    #
    # Returns the template as a Nokogiri::XML::Document
    def process
      case @tag['class']
        when 'pages' then ClassPagesTag.new(@working_dir, @template, @filename, @tag).process
        when 'menu' then ClassMenuTag.new(@working_dir, @template, @filename, @tag).process
        when 'fragment' then ClassFragmentTag.new(@working_dir, @template, @filename, @tag).process
        when 'news' then ClassNewsTag.new(@working_dir, @template, @filename, @tag).process
        else
          raise RuntimeError
      end
    end
    
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
genit-0.99 lib/genit/tags/class_tag.rb
genit-0.9 lib/genit/tags/class_tag.rb