Flask Template - For Loop Iteration key:value

Viewed 45531

I've got an HTML template with a Flask Jinja for loop in it which generates a table and looks like:

<tbody>
  {% for segment in segment_details %}
    <tr>
      <td>{{segment}}</td>
      <td>{{segment_details['{{segment}}']}}</td>
    </tr>
  {% endfor %}
</tbody>

I'm trying to iterate through a document of varying length/keys and present each row in the table as the key and value. In my Python code I've got this which has the desired response in the shell:

        for item in segment_details:
            print(item, segment_details[item])

But in Flask I get the item correctly listing all the rows but the

{{segment_details['{{segment}}']}}

Isn't producing any values, I've tried with and without the single quotes. Is this possible?

2 Answers
Related