title: Is it possible to pass variable arguments to the include tag in Mako?
body: <p>I have a mako template A that includes mako template B more than once. Mako template B expects certain arguments and I need to set them to different values on include.</p>
  
  <p>In A.mak:</p>
  
  <pre><code>&lt;%include 
      file="/components/B.mak" 
      args="lItems=some_variable, foo='bar'"
      /&gt;
  
  &lt;%include 
      file="/components/B.mak" 
      args="lItems=some_other_variable, foo='moooo'"
      /&gt;
  </code></pre>
  
  <p>In B.mak:</p>
  
  <pre><code>&lt;%page args="lItems, foo"/&gt;
  %for dItem in lItems:
      etc
  </code></pre>
  
  <p>Is this sort of thing even possible? I know it will work if I set lItems to 'some_value' and 'some_other_value' (ie: strings coded directly into A.mak) but I want to render A.mak with <code>some_variable = [some,craze,list]</code> and <code>some_other_variable = [some,other,craze,list]</code>.</p>
  
  <p>The code above gives me the error:</p>
  
  <pre><code>File ".../mako/runtime.py", line 202, in __str__
      raise NameError("Undefined")
  NameError: Undefined
  </code></pre>
  
  <p>I also tried doing the includes like so:</p>
  
  <pre><code> &lt;%include 
      file="/components/B.mak" 
      args="lItems=${some_other_variable}, foo='moooo'"
      /&gt;
  </code></pre>
  
  <p>but that's a syntax error...</p>
  
  <p>I tried it using a def also:</p>
  
  <pre><code>${the_B_def(foo='bar',lItems=some_variable)}
  </code></pre>
  
  <p>and got <code>NameError: Undefined</code>.</p>
  
  <p>So my question is: How can I pass variables to templates 'within' a template?</p>