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.31 lib/troy/xml.rb
troy-0.0.30 lib/troy/xml.rb
troy-0.0.29 lib/troy/xml.rb
troy-0.0.28 lib/troy/xml.rb
troy-0.0.27 lib/troy/xml.rb
troy-0.0.26 lib/troy/xml.rb
troy-0.0.25 lib/troy/xml.rb
troy-0.0.24 lib/troy/xml.rb
troy-0.0.23 lib/troy/xml.rb
troy-0.0.22 lib/troy/xml.rb
troy-0.0.21 lib/troy/xml.rb
troy-0.0.20 lib/troy/xml.rb
troy-0.0.19 lib/troy/xml.rb
troy-0.0.18 lib/troy/xml.rb
troy-0.0.17 lib/troy/xml.rb
troy-0.0.16 lib/troy/xml.rb
troy-0.0.15 lib/troy/xml.rb
troy-0.0.14 lib/troy/xml.rb
troy-0.0.13 lib/troy/xml.rb
troy-0.0.12 lib/troy/xml.rb