title: include file only once in jinja2 template
body: <p>Can I prevent a file from being included more than once in a template?</p>
  
  <p>Here's some (broken) sample code:</p>
  
  <pre><code># test.py
  import jinja2
  
  ENV = jinja2.Environment(loader=jinja2.FileSystemLoader('.'))
  
  template = ENV.get_template('template.html')
  print template.render({})
  </code></pre>
  
  <p>And the template looks like this:</p>
  
  <pre><code>{% include 'includejquery.html' %}
  {% include 'includejquery.html' %}
  </code></pre>
  
  <p>As you can see, I've included jquery twice (oops).  I was hoping that I could do something similar to what I would use with the C preprocessor:</p>
  
  <pre><code>{% if _JQUERY is defined %}
  {% else %}
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt;
  {% set _JQUERY = 1 %}
  {% endif %}
  </code></pre>
  
  <p>but this doesn't seem to work.  Is there any clean solution here?</p>
  
  <p>The reason I'm doing this is because I have multiple components -- It would be nice for each component to have it's own include file with everything needed to use that component.  Currently I'm factoring JQuery out of the include files, but that could get tedious as the dependencies grow and including JQuery multiple times causes some of the scripts to break.</p>