Answers.Body: <p>Many thanks for your answers and apologies for the poor example in my question. Before your answers came in I continued researching and found the twig attribute function (<a href="http://twig.sensiolabs.org/doc/functions/attribute.html" rel="nofollow">http://twig.sensiolabs.org/doc/functions/attribute.html</a>). So I did this:</p>
  
  <pre><code>{% for availability in craft.entries.section('availability2014').limit(52).find( {order: 'availabilityWeekBeginning asc'} ) %}
    {% set foo = attribute (availability, ['availability', craft.request.getSegment(2)|replace('-lake','')|capitalize]|join) %}
  
    {% for block in foo %}
        //Loop
    {% endfor %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-22T17:10:13.920Z
Answers.Text: Interesting, thanks for posting your solution!
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-22T17:03:09.430Z
Answers.LastActivityDate: 2014-06-22T17:06:59.323Z
Answers.LastEditDate: 2014-06-22T17:06:59.323Z
Answers.UserDisplayName: user1070143
Answers.Body: <p>Try this:</p>
  
  <pre><code>{% for block in availability[foo] %}
  </code></pre>
  
  <p>The square brackets let you access a variable variable name on an object.</p>
  
  <p>As a general rule you never put <code>{{ }}</code> inside of <code>{% %}</code> tags in twig.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-22T16:49:26.693Z
Answers.LastActivityDate: 2014-06-22T22:27:36.020Z
Answers.LastEditDate: 2014-06-22T22:27:36.020Z
Answers.UserDisplayName: Keith Mancuso
Answers.Body: <p>Twig isn't like ExpressionEngine, there is no "parse order" to contend with. In Twig, you <strong>cannot nest tags within other tags</strong>.</p>
  
  <p>So that line of code should look more like this:</p>
  
  <pre><code>{% for block in availability.foo %}
  </code></pre>
  
  <p>... or even this:</p>
  
  <pre><code>{% for block in availability['foo'] %}
  </code></pre>
  
  <p>Beyond that, it's difficult to tell what you are intending with your code. If this doesn't solve your problem, please expand your question with more information and we can give you a better solution.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-22T16:48:58.390Z
Answers.LastActivityDate: 2014-06-22T16:48:58.390Z
Answers.UserDisplayName: Lindsey D
Body: <p>Having already defined foo, I tried this:</p>
  
  <pre><code>{% for block in availability.{{ foo }} %}
  </code></pre>
  
  <p>This gives error:</p>
  
  <pre><code>Expected name or number
  </code></pre>
  
  <p>Can anyone please tell me the right way to go about this.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-22T15:45:46.330Z
Comments.Text: Can you give a better example of what you are trying to accomplish? What is `foo` and what is `availability`?
Comments.UserDisplayName: Victor
Tags: <tags>
Title: Is it possible to call a variable within a tag pair?
ThreadText: # Is it possible to call a variable within a tag pair?
  
  (Asked by: username_0 on 2014-06-22)
  
  Having already defined foo, I tried this:
  
  ```
  {% for block in availability.{{ foo }} %}
  
  ```
  
  This gives error:
  
  ```
  Expected name or number
  
  ```
  
  Can anyone please tell me the right way to go about this.
  
  **Tags:** tags
  
  > **Comments:**
  > **username_1**: Can you give a better example of what you are trying to accomplish? What is `foo` and what is `availability`?  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2014-06-22. Score: 1 | Accepted answer
  
  Many thanks for your answers and apologies for the poor example in my question. Before your answers came in I continued researching and found the twig attribute function (<http://twig.sensiolabs.org/doc/functions/attribute.html>). So I did this:
  
  ```
  {% for availability in craft.entries.section('availability2014').limit(52).find( {order: 'availabilityWeekBeginning asc'} ) %}
    {% set foo = attribute (availability, ['availability', craft.request.getSegment(2)|replace('-lake','')|capitalize]|join) %}
  
    {% for block in foo %}
        //Loop
    {% endfor %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_2**: Interesting, thanks for posting your solution!  
  
  ---
  
  ### Answer by username_3 on 2014-06-22. Score: 5
  
  Try this:
  
  ```
  {% for block in availability[foo] %}
  
  ```
  
  The square brackets let you access a variable variable name on an object.
  
  As a general rule you never put `{{ }}` inside of `{% %}` tags in twig.
  
  
  ---
  
  ### Answer by username_2 on 2014-06-22. Score: 1
  
  Twig isn't like ExpressionEngine, there is no "parse order" to contend with. In Twig, you **cannot nest tags within other tags**.
  
  So that line of code should look more like this:
  
  ```
  {% for block in availability.foo %}
  
  ```
  
  ... or even this:
  
  ```
  {% for block in availability['foo'] %}
  
  ```
  
  Beyond that, it's difficult to tell what you are intending with your code. If this doesn't solve your problem, please expand your question with more information and we can give you a better solution.
  
  
  ---
  
  