title: Import / include assigned variables in Jinja2
body: <p>In Jinja2, how can one access assigned variables (i.e. <code>{% set X=Y %}</code>) within files incorporated with <code>include</code>?</p>
  
  <p>I'd expect the following to work given two Jinja2 files:</p>
  
  <p><code>A.jinja</code>:</p>
  
  <pre><code>Stuff
  {% include 'B.jinja' -%}
  B has {{ N }} references
  </code></pre>
  
  <p><code>B.jinja</code>:</p>
  
  <pre><code>{% set N = 12 %}
  </code></pre>
  
  <p>I'd expect that <code>A.jinja</code>, when compiled with Jinja2, would produce the following output:</p>
  
  <pre><code>Stuff 
  B has 12 references
  </code></pre>
  
  <p>However, it produces:</p>
  
  <pre><code>Stuff
  B has  references
  </code></pre>
  
  <p>I'd be much obliged for any input as to how to access the Jinja2 variables, such as <code>N</code> above, in the file that includes the file where <code>N</code> is set.</p>
  
  <p>Thank you for reading.</p>
  
  <p>Brian</p>