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-plugin-datastruct-0.3.0 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.2.4 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.2.3 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.2.1 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.2.0 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.1.4 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.1.3 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.9.2 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-plugin-datastruct-0.1.2 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.9.1 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.9.0 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.8.8 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.8.7 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.8.6 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.8.5 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.8.4 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.8.3 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.8.2 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.8.1 lib/liquid/custom_blocks/with_json_nested_context.rb
metanorma-standoc-1.7.3 lib/liquid/custom_blocks/with_json_nested_context.rb