Assign Jinja2 block variable from for loop in view
<p>How would I replace the the hard coded '<code>python</code>' with <code>snippet['language']</code> from a for loop in my view?</p>

<pre><code>{% highlight 'python', lineno='inline' -%}
    {{snippet['code']}}
{% endhighlight %}
</code></pre>

<p>You can simply put your variable in place of the hardcoded string like this:</p>

<pre><code>{% set lang = 'python' %}
{% highlight lang %}
  from fridge import Beer
  glass = Beer(lt=500)
  glass.drink()
{% endhighlight %}
</code></pre>

<p>You haven't showed us your for-loop, but in principle you can do the same thing in the for-loop too:</p>

<pre><code>{% for lang in ['python', 'ruby', 'scheme'] %}
  {% highlight lang %}
  from fridge import Beer
  {% endhighlight %}
{% endfor %}
</code></pre>

python flask jinja2