Expand description
This module provides SDML to Value functions for constructing template contexts.
Note that the created context values are not intended as a direct 1:1 representation of either the published surface syntax grammar or the Rust model. The form is simplified for use in the template language using the following guidelines.
- Reduce layers in the model that do not add value; i.e. [Identifier
in the Rust model has an innervalue` field. - Where an
Option<T>field isNonedo not add a key in the generated object. - Where a
Vec<T>fieldis_emptydo not add a key in the generated object. - Use the key
"__type"as a discriminator where the content of an object is ambiguous, especially in arrays. - Only add
source_spanvalues for major objects such as definitions, not for individual names etc.
The upshot of this is that an if statement in a template is used to check for presence of a value
before you use it. The following demonstrates this pattern for optional fields and possibly empty
collections.
{% if module.base_uri -%}
*Base URI*: {{ module.base_uri }}
{%- endif %}
{% if module.annotations -%}
{% for ann in module.annotations -%}
{{ ann.name }}
{%- endfor %}
{%- endif %}Functionsยง
- annotation_
constraint_ to_ value - Convert a SDML
Constraintinto a context object, in the form shown as JSON below. - annotation_
property_ to_ value - Convert a SDML
AnnotationPropertyinto a context object, in the form shown as JSON below. - datatype_
to_ value - Convert a SDML
DatatypeDefinto a context object, in the form shown as JSON below. - entity_
to_ value - Convert a SDML
EntityDefinto a context object, in the form shown as JSON below. - enum_
to_ value - Convert a SDML
EnumDefinto a context object, in the form shown as JSON below. - event_
to_ value - Convert a SDML
EventDefinto a context object, in the form shown as JSON below. - member_
to_ value - Convert a SDML
Memberinto a context object, in the form shown as JSON below. - module_
to_ value - Convert a SDML
Moduleinto a context object, in the form shown as JSON below. - property_
to_ value - Convert a SDML
PropertyDefinto a context object, in the form shown as JSON below. - rdf_
to_ value - Convert a SDML
RdfDefinto a context object, in the form shown as JSON below. - structure_
to_ value - Convert a SDML
StructureDefinto a context object, in the form shown as JSON below. - type_
class_ to_ value - Convert a SDML
TypeClassDefinto a context object, in the form shown as JSON below. - union_
to_ value - Convert a SDML
UnionDefinto a context object, in the form shown as JSON below. - value_
to_ value - Convert a SDML
Valueinto a context object, in the form shown as JSON below.