Class: Liquid::CustomBlocks::WithJsonNestedContext
- Inherits:
-
Block
- Object
- Block
- Liquid::CustomBlocks::WithJsonNestedContext
- Defined in:
- lib/liquid/custom_blocks/with_json_nested_context.rb
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ WithJsonNestedContext
constructor
A new instance of WithJsonNestedContext.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ WithJsonNestedContext
Returns a new instance of WithJsonNestedContext.
4 5 6 7 |
# File 'lib/liquid/custom_blocks/with_json_nested_context.rb', line 4 def initialize(tag_name, markup, tokens) super @context_file_variable, @context_name = markup.split(",").map(&:strip) end |
Instance Method Details
#render(context) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/liquid/custom_blocks/with_json_nested_context.rb', line 9 def render(context) context_file = context[@context_file_variable].to_s.strip context[@context_name] = JSON.parse( File.read(context_file, encoding: "utf-8") ) super end |