Class: Tilt::BuilderTemplate
Overview
Builder template implementation.
Instance Attribute Summary
Attributes inherited from Template
#compiled_path, #data, #file, #line, #options
Instance Method Summary collapse
- #evaluate(scope, locals, &block) ⇒ Object
- #precompiled_postamble(locals) ⇒ Object
- #precompiled_template(locals) ⇒ Object
- #prepare ⇒ Object
Methods inherited from Template
#basename, #compiled_method, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tilt/builder.rb', line 14 def evaluate(scope, locals, &block) if @data.respond_to?(:to_str) unless locals[:xml] locals = Hash[locals] locals[:xml] = xml_builder end return super end xml = locals[:xml] || xml_builder @data.call(xml) xml.target! end |
#precompiled_postamble(locals) ⇒ Object
28 29 30 |
# File 'lib/tilt/builder.rb', line 28 def precompiled_postamble(locals) "xml.target!" end |
#precompiled_template(locals) ⇒ Object
32 33 34 |
# File 'lib/tilt/builder.rb', line 32 def precompiled_template(locals) @data.to_str end |
#prepare ⇒ Object
10 11 12 |
# File 'lib/tilt/builder.rb', line 10 def prepare @options[:indent] ||= 2 end |