Jam::Template

Parent

Generated with Razzle Dazzle Redfish.
[Validate]

Jam Templates are data-driven templates. They take valid XML/XHTML documents and expand them based on the data structures provided.

Constants

DEFAULT_ADAPTER
(Not documented)

Attributes

engine[R]

(Not documented)

Public Class Methods

load(file, adapter=DEFAULT_ADAPTER, *options) click to toggle source

New template from source file.

  • file is the file location of a source.
  • adapter is either :nokogiri, :libxml or :rexml.
  • options are per-adapter and passed through to the underlying adapter’s parser
# File lib/jam/template.rb, line 26
    def self.load(file, adapter=DEFAULT_ADAPTER, *options)
      new(File.read(file), adapter, *options)
    end
new(source, adapter=DEFAULT_ADAPTER, *options) click to toggle source

New template from source string.

  • source can be either a String or an IO object.
  • adapter is either :nokogiri, :libxml or :rexml.
  • options are per-adapter and passed through to the underlying adapter’s parser
# File lib/jam/template.rb, line 36
    def initialize(source, adapter=DEFAULT_ADAPTER, *options)
      #@engine  = Engine.new(adapter)
      @engine = Jam.const_get(adapter.to_s).new(*options)
      @source = source
    end

Public Instance Methods

document() click to toggle source
# File lib/jam/template.rb, line 43
    def document
      @document ||= engine.document(@source)
    end
expand(data) click to toggle source

Alias for render

render(data) click to toggle source

TODO: Should we render as doc, this might add a header, or render as root where it does not.

# File lib/jam/template.rb, line 50
    def render(data)
      engine.interpolate(document, data).root.to_s
    end
Also aliased as: expand
to_s() click to toggle source
# File lib/jam/template.rb, line 57
    def to_s
      document.to_s
    end

Disabled; run with --debug to generate this.