Search code examples
pythonpyramidmako

Create a table with mako


How do I create a table with alternating row highlighting using Mako? What is the mako syntax, and what do I put into the css file?

I followed the pyramid tutorial to build my own app, but I am stuck creating a good browser based user interface.


Solution

  • I assume you have data in list

    <table>
                <tr>
                          <th>Column1</th>
                          <th>Column2</th>
                          <th>Column3</th>
    
                </tr>
                % for line in table_lines:
                          % if <check condition>:
                              <tr background="black">
                          % else:
                              <tr background="white">
                          % endif
    
                          <td>${line.column1}</p>
                          <td>${line.column2}</td>
                          <td>${line.column3}</td>
                          </tr>
                % endfor
        </table>