class Xml::Kit::Template

Constants

TEMPLATES_DIR

Attributes

target[R]

Public Class Methods

new(target) click to toggle source
# File lib/xml/kit/template.rb, line 10
def initialize(target)
  @target = target
end

Public Instance Methods

to_xml(options = {}) click to toggle source

Returns the compiled template as a [String].

@param options [Hash] The options hash to pass to the template engine.

# File lib/xml/kit/template.rb, line 17
def to_xml(options = {})
  template.render(target, options)
end

Private Instance Methods

template() click to toggle source
# File lib/xml/kit/template.rb, line 33
def template
  @template ||= Tilt.new(template_path.to_s)
end
template_name() click to toggle source
# File lib/xml/kit/template.rb, line 29
def template_name
  "#{target.class.name.split('::').last.underscore}.builder"
end
template_path() click to toggle source
# File lib/xml/kit/template.rb, line 23
def template_path
  return target.template_path if target.respond_to?(:template_path)

  TEMPLATES_DIR.join(template_name)
end