Class: XbuilderTemplate
- Defined in:
- lib/xbuilder_template.rb
Constant Summary
Constants inherited from Xbuilder
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
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!(, locals = {}) case when Hash [:locals] ||= {} [:locals].merge!(xml: self) @context.render() else @context.render(, locals.merge(xml: self)) end end |