Sha256: ba2dce9c5fbe6e3fe52701ece0e221059828a14f44ce1232f9119989255a2f05

Contents?: true

Size: 956 Bytes

Versions: 6

Compression:

Stored size: 956 Bytes

Contents

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

module Genit

  # Replace a tag in a template.
  class TagProcessor
  
    # 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
      @working_dir = working_dir
      @filename = filename
      @template = template
      if tag.genit_class?
        @tag = ClassTag.new(@working_dir, @template, @filename, tag)
      elsif tag.genit_here?
        @tag = HereTag.new(@working_dir, @template, @filename, tag)
      else
        puts "Genit aborted! Unknown tag: #{tag}"
        exit 1
      end
    end
    
    # Returns the modified template as a Nokogiri::XML::Document
    def process
      @tag.process
    end
    
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
genit-2.1 lib/genit/tags/tag_processor.rb
genit-2.0 lib/genit/tags/tag_processor.rb
genit-1.0.1 lib/genit/tags/tag_processor.rb
genit-1.0 lib/genit/tags/tag_processor.rb
genit-0.99 lib/genit/tags/tag_processor.rb
genit-0.9 lib/genit/tags/tag_processor.rb