Class: Tilt::NokogiriTemplate
Constant Summary
collapse
/\A<\?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, #compiled_method, default_mime_type, default_mime_type=, #eval_file, #fixed_locals?, #initialize, #metadata, metadata, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Instance Method Details
#evaluate(scope, locals) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/tilt/nokogiri.rb', line 23
def evaluate(scope, locals)
if @data.respond_to?(:to_str)
if block_given?
super(scope, locals){yield.sub(DOCUMENT_HEADER, "")}
else
super
end
else
::Nokogiri::XML::Builder.new(&@data).to_xml
end
end
|
#precompiled_postamble(locals) ⇒ Object
40
41
42
|
# File 'lib/tilt/nokogiri.rb', line 40
def precompiled_postamble(locals)
"xml.to_xml"
end
|
#precompiled_preamble(locals) ⇒ Object
35
36
37
38
|
# File 'lib/tilt/nokogiri.rb', line 35
def precompiled_preamble(locals)
return super if locals.include? :xml
"xml = ::Nokogiri::XML::Builder.new { |xml| }\n#{super}"
end
|
#precompiled_template(locals) ⇒ Object
44
45
46
|
# File 'lib/tilt/nokogiri.rb', line 44
def precompiled_template(locals)
@data.to_str
end
|