This example demonstrates how to use an inline template, as well as
accessing the :ref:`HTML context <template_context>` available to all
datatemplate
directives, regardless of the data format.
# from conf.py
html_context = {
'sample': 'Sample context value set in conf.py',
}
.. datatemplate:json::
:source: sample.json
Individual Item
~~~~~~~~~~~~~~~
{{ data['key1'] }}
List of Items
~~~~~~~~~~~~~
{% for item in data['key2'] %}
- {{item}}
{% endfor %}
HTML Context
~~~~~~~~~~~~
{% for key, value in config.html_context.items() %}
- ``{{key}}`` = ``{{value}}``
{% endfor %}
.. datatemplate:json:: :source: sample.json Individual Item ~~~~~~~~~~~~~~~ {{ data['key1'] }} List of Items ~~~~~~~~~~~~~ {% for item in data['key2'] %} - {{item}} {% endfor %} HTML Context ~~~~~~~~~~~~ {% for key, value in config.html_context.items() %} - ``{{key}}`` = ``{{value}}`` {% endfor %}