Class: Metanorma::Plugin::Lutaml::LutamlKlassTableBlockMacro

Inherits:
Asciidoctor::Extensions::BlockMacroProcessor
  • Object
show all
Defined in:
lib/metanorma/plugin/lutaml/lutaml_klass_table_block_macro.rb

Constant Summary collapse

DEFAULT_TEMPLATE =
File.join(
  Gem::Specification.find_by_name("metanorma-plugin-lutaml").gem_dir,
  "lib", "metanorma", "plugin", "lutaml", "liquid_templates",
  "_klass_table.liquid"
)

Instance Method Summary collapse

Instance Method Details

#process(parent, target, attrs) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/metanorma/plugin/lutaml/lutaml_klass_table_block_macro.rb', line 16

def process(parent, target, attrs)
  xmi_path = Utils.relative_file_path(parent.document, target)

  if attrs["template"]
    attrs["template"] = Utils.relative_file_path(
      parent.document, attrs["template"]
    )
  end

  if attrs["guidance"]
    attrs["guidance"] = Utils.relative_file_path(
      parent.document, attrs["guidance"]
    )
  end

  path = if !attrs["path"].nil?
           attrs["path"]
         elsif !attrs["package"].nil? && !attrs["name"].nil?
           "#{attrs['package']}::#{attrs['name']}"
         else
           attrs["name"]
         end

  klass = ::Lutaml::XMI::Parsers::XML.serialize_generalization_by_name(
    xmi_path, path, attrs["guidance"]
  )

  render(klass, parent, attrs)
end