Backport/2.7/docs default lists (#56667)

* Improve rendering of default lists (#56041)

(cherry picked from commit 53ed1bfc49)

* Add compat tojson filter for jinja2 versions missing it (#56596)

(cherry picked from commit 3f4a22d8ef)
This commit is contained in:
Alicia Cozine 2019-05-21 11:48:59 -05:00 committed by GitHub
parent 9e9db8a17d
commit c452837c5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -11,6 +11,7 @@ __metaclass__ = type
import datetime
import glob
import json
import optparse
import os
import re
@ -365,6 +366,10 @@ def jinja2_environment(template_dir, typ, plugin_type):
# Jinja < 2.10
env.filters['max'] = do_max
if 'tojson' not in env.filters:
# Jinja < 2.9
env.filters['tojson'] = json.dumps
templates = {}
if typ == 'rst':
env.filters['rst_ify'] = rst_ify

View file

@ -155,7 +155,7 @@ Parameters
{% endif %}
{# Show default value, when multiple choice or no choices #}
{% if value.default is defined and value.default not in value.choices %}
<b>Default:</b><br/><div style="color: blue">@{ value.default | escape }@</div>
<b>Default:</b><br/><div style="color: blue">@{ value.default | tojson | escape }@</div>
{% endif %}
</td>
{# configuration #}