Open besessener opened 1 year ago
Hello,
If you want to combine sphinx-jinja
with sphinxcontrib.datatemplates
I would say I have the same issue.
Here is the workaround I implemented though: https://gitlab.com/uranie-cea/documentation/data-templates
In conf.py
, I defined:
jinja_contexts = {
'sentence': {'open': '{{', 'close': '}}', 'verb': 'have'}
}
And my elements.json
is simply:
{
"object": "1 hat"
}
Then I combined Jinja and Data Templates, see test.rst#L31
:
.. jinja:: sentence
:debug:
.. datatemplate:json::
:source: elements.json
I {{ verb }} {{ open }} data['object'] {{ close }}.
The order of substitutions seems to be:
So I used the open/close trick.
I also tested the other way around: Data Templates then Jinja, see _templates/test.tmpl
.
Here is the demo: https://data-templates-uranie-cea-documentation-cbd39ac5388997abccdac07.gitlab.io/test.html
Has someone a cleaner solution?
Best regards,
I am using this directive to include tables into my rst docs
In the yaml I can use inline directive like :math: or :code:.
Not sure now wether there is something similar for
.. jinja::
. I tried wrapping the jinja directive arouond datatemplate, but it did nor resolve the expressions.Is there a way to use it inline in the described context? It would be even better if I could not only use it for textual conten in the yaml file but also to add/remove some items within yaml with this approach.
Does that make sense?