Задать вопрос

Тел: +7 965 3737 888

473

Просмотров

0

Ответов

Silently-failing include tag

<p>This is the local_settings.py trick extended to Django templates.
</p>
<p>Sometimes you need to insert some arbitrary code in the HTML of the production site for external service integration like uservoice, typekit, google analytics... You don't want to put this code into source control because some other sites using the same source code may not need it.
</p>
<p>So, add this template tag to your collection and do:
</p>
{% try_to_include 'head.html' %}
<p>And leave head.html out of source control. Then when you need to include some code on your production site, just add the head.html template with the desired code to include.
</p>
<p>I usually have one included template in the header for extra &lt;head&gt; tags, and one in the footer for extra javascript.
</p>
<p>Node that the included template is rendered against the current context. If the template doesn't exist, an empty string is returned.
</p>
<p>Also see the <a href="http://bruno.im/2009/dec/07/silently-failing-include-tag-in-django/">full blog post</a> about this tag.
</p>

Вопрос полезен? Да0/Нет0
file_3496.py(1015.0б)
None