From e691e07646d3a4122d1735f4fe0f47f1fae4e8d1 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Thu, 15 Mar 2018 19:56:14 +0100 Subject: [PATCH] Fix boolean input and string-type validation --- docs/templates/plugin.rst.j2 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/templates/plugin.rst.j2 b/docs/templates/plugin.rst.j2 index 84bc5a4f66c..35bf13e41b1 100644 --- a/docs/templates/plugin.rst.j2 +++ b/docs/templates/plugin.rst.j2 @@ -95,7 +95,7 @@ Parameters
{% for i in range(1, loop.depth) %} -
+
{% endfor %}
@{ key }@ @@ -107,7 +107,7 @@ Parameters {# default / choices #}
- {# Recalculate choices and boolean values #} + {# Turn boolean values in 'yes' and 'no' values #} {% if value.default is defined %} {% if value.default == true %} {% set _x = value.update({'default': 'yes'}) %} @@ -122,10 +122,16 @@ Parameters {% if value.choices %}
    Choices: {% for choice in value.choices %} - {% if (value.default is string and choice == value.default) or (value.default is iterable and choice in value.default) %} -
  • @{ choice | escape }@ ←
  • + {# Turn boolean values in 'yes' and 'no' values #} + {% if choice == true %} + {% set choice = 'yes' %} + {% elif choice == 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) %} +
  • @{ choice | escape }@ ←
  • {% else %} -
  • @{ choice | escape }@
  • +
  • @{ choice | escape }@
  • {% endif %} {% endfor %}
@@ -240,7 +246,7 @@ Facts returned by this module are added/updated in the ``hostvars`` host facts a
{% for i in range(1, loop.depth) %} -
+
{% endfor %}
@{ key }@ @@ -304,8 +310,7 @@ Common return values are documented :ref:`here `, the foll
{% for i in range(1, loop.depth) %} -
-
+
{% endfor %}
@{ key }@ @@ -324,9 +329,9 @@ Common return values are documented :ref:`here `, the foll {% endfor %} {% endif %}
- {% if value.sample is defined and value.sample %} + {% if value.sample is defined and value.sample %}
Sample:
- {# TODO: The sample should be escaped, using | escape or | htmlify, but both mess things up beyond repair with dicts #} + {# TODO: The sample should be escaped, using |escape or |htmlify, but both mess things up beyond repair with dicts #}
@{ value.sample | replace('\n', '\n ') | html_ify }@
{% endif %}