title: jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'do'
body: <p>I'm not very familiar with Jinja and I'm having some issues using &quot;do&quot; statement in my template. I was reading other posts and I was trying to fix it but still no luck.</p>
  <p>Here is how partial output how I try to call it.</p>
  <p><strong>NOTE: my interpreter says that &quot;Extension&quot; is not used:</strong></p>
  <pre><code>import jinja2
  import csv
  from jinja2.ext import Extension
  
  
  jinja_env = jinja2.Environment(extensions=['jinja2.ext.do'])
  
  with open ('mycsv.csv') as f:
      read_csv = csv.DictReader(f)
      for line in read_csv:
          with open ( line[&quot;name&quot;] +&quot;_config.txt&quot;, 'w') as output:                    
              with open(r&quot;My_Template.j2&quot;) as t:
                  my_templ = t.read()
  
              temmplate = jinja2.Template(my_templ)
              output.write(temmplate.render(line))
  </code></pre>
  <p>Here is just example how I want to use the &quot;do&quot;, not the exact template (that is a separate file)</p>
  <pre><code>{%- for Z in range (1,X+1) %}
  {%- do  Y-=1 %}
  something {{Z}} something_else {{Y}}
  {%- endfor %}
  </code></pre>
  <p>Error:</p>
  <pre><code>jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'do'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.
  </code></pre>
  <p>===== UPDATE ======</p>
  <p>Thanks again!That works fine if I define my variables within the Jinja. But if I use variables from a csv I have some issues. I expect output like:</p>
  <pre><code>increment 1 decrement 14
  increment 2 decrement 13
  </code></pre>
  <p>So this works fine.</p>
  <pre><code>{% set one = 1 %}
  {% set fourteen = 14 %}
  {% set base = 3 %}
  {% for inc in range(base) %}
  switch {{one+base}} priority {{fourteen - base}}
  {% endfor %}
  </code></pre>
  <p>But if I try to use variables from the csv,everything is treated like a string. If I remove:</p>
  <pre><code>{% set base = 3 %}
  </code></pre>
  <p>and I get:</p>
  <pre><code>TypeError: &quot;str&quot; object cannot be interpreted as an integer.
  </code></pre>
  <p>So I tried modifying the jinja with:</p>
  <pre><code>{% set base = int(base) %}
  </code></pre>
  <p>and</p>
  <pre><code>{% set base = integer(base) %}
  </code></pre>
  <p>I get below two errors respectively:</p>
  <pre><code>jinja2.exceptions.UndefinedError: &quot;int&quot; is undefined
  jinja2.exceptions.UndefinedError: &quot;integer&quot; is undefined
  </code></pre>
  <p>If I change it within the python it says &quot;undefined&quot;:</p>
  <pre><code>base = int(line[&quot;base&quot;])
  print(base)
  print(type(base))
  
  Output:
  3
  &lt;class 'int'&gt;
  
    File &quot;&lt;template&gt;&quot;, line 6, in top-level template code
  TypeError: 'Undefined' object cannot be interpreted as an integer
  </code></pre>
  <p>This is line 6:</p>
  <pre><code>{% for inc in range(base) %}
  </code></pre>
  <p>Is there a way to tell in the Jinja template that a value is of a type integer?</p>