calculated default value

This commit is contained in:
gwen 2025-05-27 15:57:30 +02:00
parent 0293d4d455
commit ad2c9cf2ce
2 changed files with 71 additions and 0 deletions

View file

@ -277,6 +277,74 @@ It is possible to add a `variable` parameter to the `hidden` attribute like this
type: port
default: 8080
A calculated default value
-------------------------------
There is something left in the https configuration mode of the proxy:
- if the use of the proxy variables for https are the same of the proxy variables for http,
that is, if `use_for_https` is true, the https configuration variables are hidden, that's OK.
- if the use of the proxy variables for https **are not** the same of the proxy variables for http,
we would like to set their default values to the http proxy variables values.
By now, the default settings are set like this:
.. code-block:: yaml
port:
description: HTTPS Port
type: port
default: 8080
The dynamic setting of a default can be achieved in this way:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_035/firefox/20-manual.yml
:language: yaml
:caption: A default variable's value dynamically set
..
---
manual:
use_for_https:
description: Also use this proxy for HTTPS
default: true
https_proxy:
description: HTTPS Proxy
hidden:
variable: manual.use_for_https
address:
description: HTTPS address
type: domainname
params:
allow_ip: true
default:
variable: manual.http_proxy.address
port:
description: HTTPS Port
type: port
default:
variable: manual.http_proxy.port
.. note:: This is just a pointer to another variable's value.
The default values of the https address and port are pointing to the value of
the `manual.http_proxy.address` and the `manual.http_proxy.port` variables.
.. glossary::
calculated
We say that a variable's value or a default variable's value is calculated
when there is a pointer which refers to another variable's value
or if there is some :term:`jinja` code or a python function that calculates it.
.. keypoints:: Key points
**Keywords**
@ -284,6 +352,7 @@ It is possible to add a `variable` parameter to the `hidden` attribute like this
- The :term:`hidden` property set to a family
- The fact that a property can be set dynamically
- The conditional dependency of a `hidden` property that depends on a `boolean` variable.
- A calculated default value
**Progress**

View file

@ -43,5 +43,7 @@ At first glance we can see that we have a selection of five configuration option
proxymode
disabled
boolean
..
tutorial