Skip to content

Easier way of creating custom row templates #521

@simonw

Description

@simonw

I was messing around with a custom _rows_and_columns.html template and ended up with this:

{% for row in display_rows %}
  <div> 
    <hr>
    {% for cell in row %}
      {% if cell.column == "First_Name" %}
        <h2 class="scientist">{{ cell.value }}
      {% elif cell.column == "Last_Name" %}
        {{ cell.value }}</h1>
      {% elif cell.column == "Short_Description" %}
        <p><strong>{{ cell.column }}: </strong>{{ cell.value }}</p>
        <p>
      {% else %}
        <strong>{{ cell.column }}: </strong>{{ cell.value }}&nbsp;&nbsp;&nbsp;
      {% endif %}
    {% endfor %}
  </div>
{% endfor %}

This is nasty. I'd like to be able to do something like this instead:

{% for row in display_rows %}
  <h2 class="scientist">{{ row["First_Name"] }} {{ row["Last_Name"] }}</h2>
  ...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions