Class: Metanorma::Plugin::Glossarist::Liquid::WithGlossaristContext
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Metanorma::Plugin::Glossarist::Liquid::WithGlossaristContext
- Defined in:
- lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ WithGlossaristContext
constructor
A new instance of WithGlossaristContext.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ WithGlossaristContext
Returns a new instance of WithGlossaristContext.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb', line 13 def initialize(tag_name, markup, tokens) super @contexts = [] @raw_filters = {} contexts_part, filters_part = markup.strip.split(";", 2) parse_filters(filters_part.strip) if filters_part && !filters_part.strip.empty? contexts_part.split(",").each do |context| context_name, file_path = context.split("=", 2).map(&:strip) @contexts << { name: context_name, file_path: file_path } end end |
Class Method Details
.register! ⇒ Object
7 8 9 10 11 |
# File 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb', line 7 def self.register! ::Liquid::Environment.default.register_tag( "with_glossarist_context", self ) end |
Instance Method Details
#render(context) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb', line 28 def render(context) registry = context.registers[:dataset_registry] @contexts.each do |local_context| path = local_context[:file_path].strip collection = registry ? registry.load_cached(path) : load_collection(path) filtered = ConceptFilter.new(@raw_filters).apply(collection) context[local_context[:name]] = filtered.map do |c| ManagedConceptDrop.new(c) end end super end |