Class: Tilt::BuilderTemplate

Inherits:
Template show all
Defined in:
lib/tilt/builder.rb

Overview

Builder template implementation. See: builder.rubyforge.org/

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Instance Method Summary collapse

Methods inherited from Template

#basename, 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)
  xml = (locals[:xml] || ::Builder::XmlMarkup.new(options))

  if data.respond_to?(:to_str)
    if !locals[:xml]
      locals = locals.merge(:xml => xml)
    end
    return super(scope, locals, &block)
  end

  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

#prepareObject



10
11
12
# File 'lib/tilt/builder.rb', line 10

def prepare
  options[:indent] ||= 2
end