Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Before Magnolia 5.4, the only way to define (configure) templates, dialogs, apps and other definition items was only through JCR in the configuration workspace. The Magnolia 5.4 release brought 4 brought configuration via YAML as another possibility, mainly because:

...

With the release of Magnolia 5.5.4, importing and exporting JCR data can be done with YAML files. Until then this was possible only in the XML format.

...

ItemYAML fileCorresponding definition class*
DialogmyDialog.yaml

Javadoc-resource-link-macro
0info.magnolia.ui.dialog.definition.DialogDefinition
rangeHigherVersion5.7
classNameinfo.magnolia.ui.dialog.definition.DialogDefinition
renderTypeasynchronous

TemplatemyTemplate.yaml

Javadoc-resource-link-macro
0info.magnolia.rendering.template.TemplateDefinition
rangeHigherVersion5.7
classNameinfo.magnolia.rendering.template.TemplateDefinition
renderTypeasynchronous

AppmyApp.yaml

Javadoc-resource-link-macro
0info.magnolia.ui.api.app.AppDescriptor
rangeHigherVersion5.7
classNameinfo.magnolia.ui.api.app.AppDescriptor
renderTypeasynchronous

* You can also use custom definition classes which will usually extend the classes mentioned above. In this case you have to provide the class as an attribute in the YAML file.

Deprecating a YAML-based definition with !metadata

The introduction of the info.magnolia.config.source.yaml.construct.WrapMetadata construct in Magnolia 5.6.2 allows you to deprecate YAML-based definitions. You can mark a YAML-based definition as deprecated like this:

...

  • Deprecated classes used by any definition.
  • Deprecated or non-existing templates used by block definitions.
  • Deprecated or non-existing page template definitions referenced from site definitions.
  • Deprecated or non-existing theme definitions referenced from site definitions.
  • Template references.
    • Deprecated or non-existing dialogs
    • Deprecated or non-existing component definitions used in page definitions.
    • Non-existing template script paths.
    • Configured but non-existing renderer.

...

Magnolia provides two mechanisms to reuse a configuration within a YAML-file: !inherit and !include . You can use them not only to reuse a definition but also to modify a reused definition.

YAML inherit

Use the Magnolia !inherit directive to inherit a registered definition item in order to create a new definition item, and then modify the new item according to your needs. This directive is very similar to JCR extends. The item you inherit the definition from is referenced by its identifier.

...

For more information read the YAML inherit and include page.

YAML include

Use the Magnolia !include directive to add a reusable YAML chunk. Include a fragment on a sub-level of your new definition or include a complete definition on top of your new definition. Reference the file you include by its resource path. The path to such a resource has the following pattern: /<module-name>/path/to/the/reusable/chunk.yaml .

You can also modify the included part of the definition.

Tip

If your !include file is not working, check that the first line in the included YAML file does not have any indentation.

Syntactic variants of the directive

...