Class: Lvr::Template
- Inherits:
-
Object
- Object
- Lvr::Template
- Defined in:
- lib/lvr/template.rb,
lib/lvr/template/tags.rb,
lib/lvr/template/filters.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(**options) ⇒ void constructor
-
#load(input_path) ⇒ Template
‘self`.
-
#parse(input) ⇒ Template
‘self`.
- #render(**context) ⇒ Object
Constructor Details
#initialize(**options) ⇒ void
24 25 26 27 28 29 30 |
# File 'lib/lvr/template.rb', line 24 def initialize(**) @env = Liquid::Environment.new @env.register_filter(Lvr::Template::Filters) @env.register_tag('footer', Lvr::Template::Tags::Footer) @template = Liquid::Template.new(environment: @env) @options = end |
Class Method Details
.load(input_path) ⇒ Template
14 |
# File 'lib/lvr/template.rb', line 14 def self.load(input_path) = self.new.load(input_path) |
.parse(input) ⇒ Template
19 |
# File 'lib/lvr/template.rb', line 19 def self.parse(input) = self.new.parse(input) |
Instance Method Details
#load(input_path) ⇒ Template
Returns ‘self`.
35 36 37 38 |
# File 'lib/lvr/template.rb', line 35 def load(input_path) @template.parse(File.read(input_path.to_s)) self end |
#parse(input) ⇒ Template
Returns ‘self`.
43 44 45 46 |
# File 'lib/lvr/template.rb', line 43 def parse(input) @template.parse(input.to_s) self end |
#render(**context) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/lvr/template.rb', line 51 def render(**context) @template.render!(context.deep_stringify_keys!, { error_mode: :strict, strict_filters: true, strict_variables: true, }.merge(@options)) end |