You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Templates are blueprints for creating pages, areas and components. When you add a page in the Pages app you must choose a template.

A template consists of:

Template definition

required

A template definition gives a template a name and makes it available to the system. At a minimum a template definition must specify a script and a renderer.

Template script

required

A template script defines the output, typically HTML, and is interpreted by a Renderer. The script is written in a templating language such as FreeMarker.

In the context of developing Single-page applications, the elements comparable to FreeMarker template scripts are components, which are compiled into a single HTML page. On the Magnolia side, the rendering of the page is handled by the SPA renderer.

Dialog definition

optional

Model

optional

The model is a JavaBean implementing

$webResourceManager.requireResource("info.magnolia.sys.confluence.artifact-info-plugin:javadoc-resource-macro-resources") RenderingModel
. Use it to implement complex logic. The model can execute any Java code to retrieve data from the repository or from an external source. The results are available to the template script for rendering on the page.

optional

The model can be implemented in Java or via JavaScript. Use models to implement complex logic. The results are available to the template script for rendering on the page.

A Java model is a bean implementing RenderingModel. The model can execute any Java code to retrieve data from the repository or from an external source.

In order to use JavaScript models, make sure the Magnolia instance contains the JavaScript Models module.

If developing a Single-page application, templating takes form of building Angular or ReactJS components, which are compiled into a single HTML page. On the Magnolia side, the rendering of the page is handled by the SPA renderer and the associated SPA helper libraries.

For an overview, see the Single-page applications page.


Elements of the Magnolia template mechanism:

(warning) The diagram abbreviates the field class as i.m.u.f.f.d.TextFieldDefinition to save space. This is not a valid value. Use fully-qualified field class names such as info.magnolia.ui.form.field.TextFieldDefinition in your definitions.

The Magnolia CLI speeds up template creation for light developers. The tool provides commands that automatically create basic template definitions and scripts on the file system.

#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels