How to pass HTML to an included template

爷,独闯天下 提交于 2019-12-08 13:25:04

问题


Using Djangos template language I would like to pass HTML generated through the template language into an included template like in the following simplified example:

field.html

<input name="input_name" />
<div>{{ input_desc_html }}</div>

form.html

{% with input_name="test" input_desc_html=... %}
    ... should read {% for this in that %} {{ this }} {% endfor %}
    {% include 'field.html' %}
{% endwith %}

Obvioulsy there is something missing at ... and I do not know how to advance from here. Is this approach even possible and if yes, how?

If not, what else would you suggest? I thought about using blocks and extending field.html, but it seems to me that this needs every field in its own file - or can I have local templates?

来源:https://stackoverflow.com/questions/22962957/how-to-pass-html-to-an-included-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!