我的问题基本上是关于渲染变量。例如,假设我有一个对象块,其中 block.text='{{ "hello"|trans }}'
我想将其包含在我的基本模板中。以下显然不适用于我的意图。
{% include block.text %}
我如何将它渲染到我的模板中?
我的问题基本上是关于渲染变量。例如,假设我有一个对象块,其中 block.text='{{ "hello"|trans }}'
我想将其包含在我的基本模板中。以下显然不适用于我的意图。
{% include block.text %}
我如何将它渲染到我的模板中?
It does not seem a good idea generate dynamic templates from view side to render into a template.
But remember do you have other elegant approach like:
Also, take in mind, that you can use IF statement into a template to include or not include some template and, also, you can pass additional context to the included template using keyword arguments (ex: {% include "name_snippet.html" with person="Jane" greeting="Hello" %}
).