rougail/docs/structured_data/condition.rst

277 lines
7.4 KiB
ReStructuredText
Raw Normal View History

2023-12-17 20:25:53 +01:00
Calculated properties
==========================
Synopsis
------------
2026-06-06 19:22:36 +02:00
Calculated properties allow you to add or remove properties to a :term:`variable` or a :term:`family` depending on the context.
2023-12-17 20:25:53 +01:00
Here is the list of editable properties:
2026-06-06 19:22:36 +02:00
.. list-table::
2023-12-17 20:25:53 +01:00
:widths: 15 15 25
:header-rows: 1
2026-06-06 19:22:36 +02:00
* - Attribute applying to
- Property's name
2023-12-17 20:25:53 +01:00
- Comment
2026-06-06 19:22:36 +02:00
2023-12-17 20:25:53 +01:00
* - Variable
2026-06-06 19:22:36 +02:00
Family
2023-12-17 20:25:53 +01:00
- hidden
2026-06-06 19:22:36 +02:00
- Hides a variable or a family, in this case it is not accessible in `read-write` mode,
but remains accessible in a calculation or in `read-only` mode.
.. seealso:: :ref:`hidden access control <hidden>`.
2023-12-17 20:25:53 +01:00
* - Variable
2026-06-06 19:22:36 +02:00
Family
2023-12-17 20:25:53 +01:00
- disabled
2026-06-06 19:22:36 +02:00
- Deactivates a variable or family, in this case it is never accessible.
.. seealso:: :ref:`disabled access control <disabled>`.
* - Variable
- frozen
- A frozen variable is a variable that the :term:`operator` cannot change the value.
2023-12-17 20:25:53 +01:00
* - Variable
- mandatory
2026-06-06 19:22:36 +02:00
- The variable expects a value other than `null` (or `None` in Python) or `[]` for multiple variables.
.. seealso:: for non multiple variables we call it a :ref:`nullable variable <nullable_variable>`.
* - Variable
- empty
- The multiple variable allow the value `null` (or `None` in Python)
.. seealso:: we call it a :ref:`nullable variable <nullable_variable>`.
2023-12-17 20:25:53 +01:00
A property can be calculated. In this case we have two possibilities:
2026-06-06 19:22:36 +02:00
- calculation via Jinja (see also the tutorial with a real world sample :doc:`variable jinja <../tutorial/jinja>`)
- calculation via a variable (see also the tutorial with a real world sample :doc:`variable calculation <../tutorial/properties>`)
2023-12-17 20:25:53 +01:00
Parameters
---------------
2026-06-06 19:22:36 +02:00
Variable parameters
~~~~~~~~~~~~~~~~~~~
.. list-table::
2023-12-17 20:25:53 +01:00
:header-rows: 1
2026-06-06 19:22:36 +02:00
* - Parameter
- Comment
- Sample
* - type
`string`
- Calculation type.
This parameter is optional. It is deduced from the presence of the parameter "variable" in a calculation.
- variable
* - variable
2023-12-17 20:25:53 +01:00
`string`
2026-06-06 19:22:36 +02:00
2023-12-17 20:25:53 +01:00
`mandatory`
2026-06-06 19:22:36 +02:00
- Name of the associated variable.
It's better to use :term:`relative path` notation.
- _.my_variable
* - when/when_not
- Compare the value of the variable define in `variable` attribute.
If the related variable is the boolean typed variable, the default value is `true`
- See the tutorial with a real world sample :doc:`when_not <../tutorial/properties>`)
* - propertyerror
`boolean` or `transitive`
- If access to the variable is not possible due to a property
(for example `disabled`) by default an error is returned.
The overall coherence is not guaranteed.
If the parameter is `false`, the calculated value is `false` in this condition.
If the parameter is `transitive`, the calculated is `true` if the variable raise propertyerror
or `false` otherwise.
Default value: `true`
- transitive
false
* - optional
`boolean`
- The variable in calculation may not exist. This generates an error. Overall coherence is not guaranteed.
To avoid this set the optional parameter to `true`. In this case, if variable in calculation is not exists, the variable is always accessible.
- true
* - default
`boolean`
- If optional parameter is set to `true` and the variable in calculation is not exist, the variable is accessible.
If you do not want this behavior, set this parameter to `false`.
- false
* - description
`string`
- Rougail engine create a description like "when the variable "xxxx" has the value "yyyy".
You can personnalize here the calculation description
-
Jinja parameters
~~~~~~~~~~~~~~~~
.. list-table::
:header-rows: 1
* - Parameter
- Comment
- Sample
* - type
`string`
- The calculation type.
This parameter is optional. It is deduced from the presence of the parameter "jinja" in calculation.
2023-12-17 20:25:53 +01:00
- jinja
2026-06-06 19:22:36 +02:00
* - jinja
2023-12-17 20:25:53 +01:00
`string`
2026-06-06 19:22:36 +02:00
2023-12-17 20:25:53 +01:00
`mandatory`
2026-06-06 19:22:36 +02:00
- Jinja template. For a multiple variable, each line represents a value.
It's better to use :term:`relative path` notation in Jinja template.
- .. code-block:: jinja
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
{% if _.my_variable %}
{{ _.my_variable }}
{% endif %}
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
* - params
`dict`
2023-12-17 20:25:53 +01:00
- Additional parameters passed to the Jinja template
2026-06-06 19:22:36 +02:00
See below to have params possibility.
- See the tutorial with a real world sample :doc:`params <../tutorial/jinja>`)
* - return_type
2023-12-17 20:25:53 +01:00
`string`
2026-06-06 19:22:36 +02:00
- Jinja template could return two type of value:
- `string` (default): that means the Jinja template return an error message that explain why we don't have access to this variable
- `boolean`: the Jinja template return "true" or "false". The value true means that the properties is present.
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
- See the tutorial with a real world sample :doc:`return_type <../tutorial/jinja>`)
* - description
`string`
`recommanded`
- Rougail engine cannot deduce what you want to do in Jinja template. You have to describe it for documentation purpose.
If return_type parameter is `boolean`, this description is used in error message.
- See the tutorial with a real world sample :doc:`description <../tutorial/jinja>`)
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
In the case of a Jinja type calculation, it is possible to have parameters (`params`).
2023-12-17 20:25:53 +01:00
There are two types of parameter:
- the standard parameters (string, boolean, integer, null), in this case just do: "key: value"
- advanced settings:
- parameter via a variable
- parameter via information
2026-06-06 19:22:36 +02:00
- parameter via an identifier: in the case of a variable in a :term:`dynamically built family`
- parameter via an index: in the case of a variable in a :term:`sequence`
- parameter via the current :term:`namespace`
Parameters for variable type `param`
''''''''''''''''''''''''''''''''''''
.. list-table::
2023-12-17 20:25:53 +01:00
:header-rows: 1
2026-06-06 19:22:36 +02:00
* - Parameter
- Comments
- Sample
* - type
2023-12-17 20:25:53 +01:00
`string`
2026-06-06 19:22:36 +02:00
- Parameter's type
- variable
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
* - variable
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
`string`
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
`mandatory`
- Variable's name
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
It's better to use :term:`relative path` notation.
- _.my_variable
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
* - propertyerror
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
`boolean`
- If access to the variable is not possible due to a property (for example `disabled`) by default an error is returned. If the parameter is false, the parameter is not passed to the Jinja template.
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
Default value: `true`
- false
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
* - optional
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
`boolean`
- The variable may not exist depending on YAML file imports. If the optional parameter is true, the parameter will simply be deleted if the variable does not exist.
Default value: `false`
- true
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
* - whole
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
`boolean`
- In :term:`sequence` family, only the value of the variable in the current element is propose.
This parameter allow you to have all values for all elements.
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
Default value: `false`.
- true
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
Parameters for information type `param`
'''''''''''''''''''''''''''''''''''''''
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
.. list-table::
:header-rows: 1
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
* - Parameter
- Comments
- Sample
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
* - information
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
`string`
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
`mandatory`
- Name of the information whose value we want to retrieve.
- doc
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
* - variable
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
`string`
- Variable's name. If not specified, the information is retrieve in :term:`Tiramisu` Config.
2023-12-17 20:25:53 +01:00
2026-06-06 19:22:36 +02:00
It's better to use :term:`relative path` notation.
- _.my_variable