Sha256: 1f36bd9ecb487169515cf9b94a48f497653686cc1431e97c3d31e0b0c257a171

Contents?: true

Size: 589 Bytes

Versions: 31

Compression:

Stored size: 589 Bytes

Contents

module Troy
  class XML
    # The XML content.
    #
    attr_reader :content

    # The data that must be rendered within
    # the Troy::Context object.
    #
    attr_reader :data

    def initialize(content, data)
      @content = content
      @data = data
    end

    def context
      @context ||= Context.new(data.merge(:xml => xml)).extend(Helpers)
    end

    def xml
      @xml ||= Builder::XmlMarkup.new(:indent => 2)
    end

    def to_xml
      @to_xml ||= begin
        xml.instruct!
        context.instance_eval(content)
        xml.target!
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
troy-0.0.11 lib/troy/xml.rb
troy-0.0.10 lib/troy/xml.rb
troy-0.0.9 lib/troy/xml.rb
troy-0.0.8 lib/troy/xml.rb
troy-0.0.7 lib/troy/xml.rb
troy-0.0.6 lib/troy/xml.rb
troy-0.0.5 lib/troy/xml.rb
troy-0.0.4 lib/troy/xml.rb
troy-0.0.3 lib/troy/xml.rb
troy-0.0.2 lib/troy/xml.rb
troy-0.0.1 lib/troy/xml.rb