Class: Tilt::LiquidTemplate
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/liquid.rb
Overview
Liquid template implementation. See: liquidmarkup.org/
Liquid is designed to be a safe template system and threfore does not provide direct access to execuatable scopes. In order to support a scope
, the scope
must be able to represent itself as a hash by responding to #to_h. If the scope
does not respond to #to_h it will be ignored.
LiquidTemplate does not support yield blocks.
It’s suggested that your program require ‘liquid’ at load time when using this template engine.
Instance Attribute Summary
Attributes inherited from Template
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
#allows_script? ⇒ Boolean
34 35 36 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/liquid.rb', line 34 def allows_script? false end |
#evaluate(scope, locals, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/liquid.rb', line 23 def evaluate(scope, locals, &block) locals = locals.inject({}){ |h,(k,v)| h[k.to_s] = v ; h } if scope.respond_to?(:to_h) scope = scope.to_h.inject({}){ |h,(k,v)| h[k.to_s] = v ; h } locals = scope.merge(locals) end locals['yield'] = block.nil? ? '' : yield locals['content'] = locals['yield'] @engine.render(locals) end |
#prepare ⇒ Object
19 20 21 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/liquid.rb', line 19 def prepare @engine = ::Liquid::Template.parse(data, ) end |