Class: Xml::Kit::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/xml/kit/template.rb

Constant Summary collapse

TEMPLATES_DIR =
Pathname.new(File.join(__dir__, 'templates/'))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Template

Returns a new instance of Template.



10
11
12
# File 'lib/xml/kit/template.rb', line 10

def initialize(target)
  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



8
9
10
# File 'lib/xml/kit/template.rb', line 8

def target
  @target
end

Instance Method Details

#to_xml(options = {}) ⇒ Object

Returns the compiled template as a [String].

Parameters:

  • options (Hash) (defaults to: {})

    The options hash to pass to the template engine.



17
18
19
# File 'lib/xml/kit/template.rb', line 17

def to_xml(options = {})
  template.render(target, options)
end