One of the most widely used elements in the Giotto language is the Container.
A container is used to define a set of objects that share a common configuration.
Additionally, a container can be made replicable.
To define a container, use the mn:container
attribute.
<div mn:container>This is a container</div>
You can therefore:
- Define the parameters of a container;
- Make a container repeatable;
- Associate parameters with a container;
Container parameters
To configure a container, you need to associate parameters with it.
To declare a parameter use the mn:param
attribute.
If you define a parameter in the body of the communication, it will be valid for the entire document.
Its configuration will be done through a specific Styles button. It will thus be possible to define a global configuration of the communication, for example setting a background color or a general text attribute.
If a parameter is defined at the container level, its validity will be limited to just that container.
<div mn:container> <meta mn:param mn:name="Color" mn:type="color" mn:default="#E5E5E5" /> <meta mn:param mn:name="showtext" mn:type="boolean" mn:default="true" mn:tab="Options" mn:section="Display options" mn:label="Show News text" mn:help="It's optional" /> <div style="background-color:[param:color];"> Container with parameters <span mn:if="param.showtext">News</span> </div> </div>
Repeatable containers
One of the main advantages of using a Container is that it can be made repeatable.
The use of the container is very useful, for example, when you want to allow users to quickly insert articles.
To make a container repeatable, use the mn:repeatable
attribute.
<div mn:container mn:repeatable> <meta mn:param mn:name="testo" mn:type="text" mn:default="Testo" /> Repeatable container containing editable content with a configurable parameter [param:testo] </div>
You can define a minimum and maximum number of times the container can be repeated.
To do this, you can use the optional attributes mn:min
and mn:max
.
If an mn:min
is defined, the indicated number of containers will be automatically created.
The default values of mn:min
and mn:max
are 1 and 0 respectively, where 0 means infinite. If other than 0, the value of mn:max
must be greater than that of mn:min
.
<div mn:container mn:repeatable mn:min="2" mn:max="4"> <div mn:editable> This content can be repeated between 2 and 4 times </div> </div>
Container parameters
By leveraging the platform interface, you can configure specific parameters within the container.
To create a modifiable parameter, use the mn:editparam
attribute, through which the parameter to configure is indicated.
<div mn:container mn:repeatable> <meta mn:param mn:name="testo" mn:type="text" mn:default="Testo" /> Modifiable parameter: <span mn:editable mn:editparam="testo"></span> and non-modifiable: [param:testo] </div>