diff options
author | Dag Wieers <dag@wieers.com> | 2018-03-20 23:08:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-20 23:08:55 +0100 |
commit | b8e07f0d6efe27b7c7ecaa992700353e38c88984 (patch) | |
tree | d54b3729e547c13348489de04a071dadc5f8f95e /docs/templates | |
parent | b7aa41b9b937df7af6afa1404be5c9c3d85f0948 (diff) | |
download | ansible-b8e07f0d6efe27b7c7ecaa992700353e38c88984.tar.gz |
Add a few Jinja2 tests to simplify template (#37514)
Add list test to simplify template
Diffstat (limited to 'docs/templates')
-rw-r--r-- | docs/templates/plugin.rst.j2 | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/docs/templates/plugin.rst.j2 b/docs/templates/plugin.rst.j2 index 35bf13e41b..c146389a98 100644 --- a/docs/templates/plugin.rst.j2 +++ b/docs/templates/plugin.rst.j2 @@ -108,12 +108,10 @@ Parameters <td> <div class="cell-border"> {# Turn boolean values in 'yes' and 'no' values #} - {% if value.default is defined %} - {% if value.default == true %} - {% set _x = value.update({'default': 'yes'}) %} - {% elif value.default == false %} - {% set _x = value.update({'default': 'no'}) %} - {% endif %} + {% if value.default is sameas true %} + {% set _x = value.update({'default': 'yes'}) %} + {% elif value.default is sameas false %} + {% set _x = value.update({'default': 'no'}) %} {% endif %} {% if value.type == 'bool' %} {% set _x = value.update({'choices': ['no', 'yes']}) %} @@ -123,12 +121,12 @@ Parameters <ul><b>Choices:</b> {% for choice in value.choices %} {# Turn boolean values in 'yes' and 'no' values #} - {% if choice == true %} + {% if choice is sameas true %} {% set choice = 'yes' %} - {% elif choice == false %} + {% elif choice is sameas false %} {% set choice = 'no' %} {% endif %} - {% if (value.default is string and value.default == choice) or (value.default is iterable and value.default is not string and choice in value.default) %} + {% if (value.default is string and value.default == choice) or (value.default is list and choice in value.default) %} <li><div style="color: blue"><b>@{ choice | escape }@</b> ←</div></li> {% else %} <li>@{ choice | escape }@</li> |