Class: Tilt::NokogiriTemplate
- Inherits:
-
Template
show all
- Defined in:
- lib/vendor/tilt-1.4.1/lib/tilt/nokogiri.rb
Overview
Constant Summary
collapse
/^<\?xml version=\"1\.0\"\?>\n?/
Instance Attribute Summary
Attributes inherited from Template
#data, #file, #line, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Template
#allows_script?, #basename, #default_encoding, #eval_file, #initialize, #name, #read_template_file, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Class Method Details
.engine_initialized? ⇒ Boolean
10
11
12
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/nokogiri.rb', line 10
def self.engine_initialized?
defined? ::Nokogiri
end
|
Instance Method Details
#evaluate(scope, locals) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/nokogiri.rb', line 20
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
|
#initialize_engine ⇒ Object
14
15
16
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/nokogiri.rb', line 14
def initialize_engine
require_template_library 'nokogiri'
end
|
#precompiled_postamble(locals) ⇒ Object
34
35
36
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/nokogiri.rb', line 34
def precompiled_postamble(locals)
"xml.to_xml"
end
|
#precompiled_preamble(locals) ⇒ Object
29
30
31
32
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/nokogiri.rb', line 29
def precompiled_preamble(locals)
return super if locals.include? :xml
"xml = ::Nokogiri::XML::Builder.new { |xml| }\n#{super}"
end
|
#precompiled_template(locals) ⇒ Object
38
39
40
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/nokogiri.rb', line 38
def precompiled_template(locals)
data.to_str
end
|
18
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/nokogiri.rb', line 18
def prepare; end
|