title: Django - Can't access variable defined with template tag outside for loop
body: <p>In a Django template, I have to signal that the <code>if</code> conditional was entered and for this I created a template tag:</p>
  <pre><code>@register.simple_tag
  def setvar(val=None):
      return val
  </code></pre>
  <p>And in my template I have:</p>
  <pre><code>&lt;div&gt;
      {% for item in items %}
          {% if &lt;!-- condition --&gt; %}
              {% setvalor '1' as has_favorites %}
          {% endif %}
      {% endfor %}
      &lt;div&gt;{{ has_favorites }}&lt;/div&gt;  &lt;!-- testing --&gt;
  &lt;/div&gt;
  </code></pre>
  <p>The variable <code>has_favorites</code> is not rendered in the browser. It seems that the variable is only available in the <code>for</code> loop scope.</p>
  <p>Is there a way to workaround that?</p>