title: Variable scope in Shopify Sections
body: <p>I'm trying to use a variable in my section file but it doesn't appear to be inherited from it's parent template.</p>
  
  <p>For example:</p>
  
  <p><strong>index.liquid</strong></p>
  
  <pre><code>{% assign foo = "bar" %}
  {% section 'example' %}
  </code></pre>
  
  <p><strong>sections/example.liquid</strong></p>
  
  <pre><code>&lt;h1&gt;{{ foo }}&lt;/h1&gt;
  
  {% schema %}
  {
      "name": "Example",
      "settings": [
         ...
      ]
  }
  {% endschema %}
  </code></pre>
  
  <p>It will not output the value of <code>{{ foo }}</code>, instead I just get: <code>&lt;h1&gt;&lt;/h1&gt;</code> as if the variable was never defined.</p>
  
  <p>I thought sections would work like snippets, where anything defined in the parent template would be in scope in the included snippet:</p>
  
  <p><strong>index.liquid</strong></p>
  
  <pre><code>{% assign foo = "bar" %}
  {% include 'example' %}
  </code></pre>
  
  <p><strong>snippets/example.liquid</strong></p>
  
  <pre><code>&lt;h1&gt;{{ foo }}&lt;/h1&gt;
  </code></pre>
  
  <p>Where I would get <code>&lt;h1&gt;bar&lt;/h1&gt;</code> when rendered.</p>
  
  <ul>
  <li>Is this a bug, or intended behaviour?</li>
  <li>Is there a way I can include a section and use variable from some form of outer-scope?</li>
  </ul>
  
  <p>Thanks!</p>