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

Тел: +7 965 3737 888





Silently-failing include tag

<p>This is the local_settings.py trick extended to Django templates.
<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>So, add this template tag to your collection and do:
{% 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>I usually have one included template in the header for extra &lt;head&gt; tags, and one in the footer for extra javascript.
<p>Node that the included template is rendered against the current context. If the template doesn't exist, an empty string is returned.
<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.

Вопрос полезен? Да0/Нет0