Class: Tilt::NokogiriTemplate
Overview
Constant Summary
collapse
/^<\?xml version=\"1\.0\"\?>\n?/
Instance Attribute Summary
Attributes inherited from Template
#compiled_path, #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) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/tilt/nokogiri.rb', line 13
def evaluate(scope, locals)
if data.respond_to?(:to_str)
wrapper = proc { yield.sub(DOCUMENT_HEADER, "") } if block_given?
super(scope, locals, &wrapper)
else
::Nokogiri::XML::Builder.new.tap(&data).to_xml
end
end
|
#precompiled_postamble(locals) ⇒ Object
27
28
29
|
# File 'lib/tilt/nokogiri.rb', line 27
def precompiled_postamble(locals)
"xml.to_xml"
end
|
#precompiled_preamble(locals) ⇒ Object
22
23
24
25
|
# File 'lib/tilt/nokogiri.rb', line 22
def precompiled_preamble(locals)
return super if locals.include? :xml
"xml = ::Nokogiri::XML::Builder.new { |xml| }\n#{super}"
end
|
#precompiled_template(locals) ⇒ Object
31
32
33
|
# File 'lib/tilt/nokogiri.rb', line 31
def precompiled_template(locals)
data.to_str
end
|
#prepare ⇒ Object
11
|
# File 'lib/tilt/nokogiri.rb', line 11
def prepare; end
|