"DTD/xhtml1-strict.dtd">
Class Amrita::MergeTemplate
In: lib/amrita/merge.rb
lib/amrita/compiler.rb
Parent: Object
Methods
amrita_expand_element    amrita_get_data    merge_templates    new    read_template   
Included modules
Amrita::DictionaryData
Public Class methods
new(dir=nil, &block) {|| ...}
# File lib/amrita/merge.rb, line 9
    def initialize(dir=nil, &block)
      @dir = dir
      if block_given?
        @body = yield
      else
        @body = nil
      end
    end
Public Instance methods
amrita_get_data(key, element, context)
# File lib/amrita/merge.rb, line 18
    def amrita_get_data(key, element, context)
      amrita_expand_element(element, context)
    end
amrita_expand_element(e, context)
# File lib/amrita/merge.rb, line 22
    def amrita_expand_element(e, context)
      case e.hid
      when /(.*)#(.*)/
        fname, data_id = $1, $2
        e = merge_templates(fname, data_id, e, context)
      else
        e.init_body do
          e.body.expand1(self, context)
        end
      end

      if @body
        e.expand(@body, context)
      else
        e
      end
    end
merge_templates(fname, data_id, e, context)
# File lib/amrita/merge.rb, line 40
    def merge_templates(fname, data_id, e, context)
      h = read_template(fname)
      ee = h.find {|e| e[:id] == data_id }
      raise "no match for #{data_id}" unless ee
      ee.delete_attr!(:id)
      ee
    end
read_template(fname)
# File lib/amrita/merge.rb, line 48
    def read_template(fname)
      fname = @dir + "/" + fname if @dir
      HtmlParser.parse_file fname
    end