Class: Tilt::JsonitTemplate
- Inherits:
-
Template
- Object
- Template
- Tilt::JsonitTemplate
- Defined in:
- lib/jsonit/tilt/tilt_jsonit.rb
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate(scope, locals, &block) ⇒ Object
- #initialize_engine ⇒ Object
- #precompiled_postamble(locals) ⇒ Object
- #precompiled_preamble(locals) ⇒ Object
- #precompiled_template(locals) ⇒ Object
- #prepare ⇒ Object
Class Method Details
.engine_initialized? ⇒ Boolean
6 7 8 |
# File 'lib/jsonit/tilt/tilt_jsonit.rb', line 6 def self.engine_initialized? defined? ::Jsonit end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/jsonit/tilt/tilt_jsonit.rb', line 16 def evaluate(scope, locals, &block) return super(scope, locals, &block) if data.respond_to?(:to_str) json = ::Jsonit::Builder.new data.call(json) end |
#initialize_engine ⇒ Object
10 11 12 |
# File 'lib/jsonit/tilt/tilt_jsonit.rb', line 10 def initialize_engine require_template_library 'jsonit' end |
#precompiled_postamble(locals) ⇒ Object
26 27 28 |
# File 'lib/jsonit/tilt/tilt_jsonit.rb', line 26 def precompiled_postamble(locals) "\nend.to_json" end |
#precompiled_preamble(locals) ⇒ Object
22 23 24 |
# File 'lib/jsonit/tilt/tilt_jsonit.rb', line 22 def precompiled_preamble(locals) "\n#{super};::Jsonit::Builder.new do |json|" end |
#precompiled_template(locals) ⇒ Object
30 31 32 |
# File 'lib/jsonit/tilt/tilt_jsonit.rb', line 30 def precompiled_template(locals) data.to_str end |
#prepare ⇒ Object
14 |
# File 'lib/jsonit/tilt/tilt_jsonit.rb', line 14 def prepare; end |