Class: XbuilderTemplate

Inherits:
Xbuilder
  • Object
show all
Defined in:
lib/xbuilder_template.rb

Constant Summary

Constants inherited from Xbuilder

Xbuilder::XML

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Xbuilder

#<<, #cdata!, #comment!, #declare!, #initialize, #instruct!, #method_missing, #tag!, #target!, #text!

Constructor Details

This class inherits a constructor from Xbuilder

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Xbuilder

Class Method Details

.encode(context) {|xml| ... } ⇒ Object

Yields:

  • (xml)


4
5
6
7
8
9
# File 'lib/xbuilder_template.rb', line 4

def self.encode(context)
  xml = self.new
  xml.__instance_variable_set(:@context, context)
  yield xml
  xml.target!
end

Instance Method Details

#partial!(options, locals = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/xbuilder_template.rb', line 11

def partial!(options, locals = {})
  case options
  when Hash
    options[:locals] ||= {}
    options[:locals].merge!(xml: self)
    @context.render(options)
  else
    @context.render(options, locals.merge(xml: self))
  end
end