Sha256: fc29bccf9166ca0cb824e8b7eb813914df61abf5c01f87beeca7523dfd91d66d

Contents?: true

Size: 469 Bytes

Versions: 30

Compression:

Stored size: 469 Bytes

Contents

module Liquid
  module CustomBlocks
    class WithJsonNestedContext < Block
      def initialize(tag_name, markup, tokens)
        super
        @context_file_variable, @context_name = markup.split(",").map(&:strip)
      end

      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
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
metanorma-standoc-1.7.2 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.7.1 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.7.0 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.6.5 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.6.4 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.6.3 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.1.1 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.6.2 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.6.1 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.1.0 lib/liquid/custom_blocks/with_json_nested_context.rb