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