0

I am trying to produce table headings using loop in flash but I get new lines after each:

{% extends "layout.html" %}

{% block title %}
    Portfolio overview
{% endblock %}

{% block main %}

{% for variable in variables -%}
    {% for key, value in variable.items() -%}
    <table>
       <thead><th>{{ key }}</th></thead>
    {% endfor -%}
    {% for key, value in variable.items() -%}    
    <tbody>    
    <td>{{ value }}</td>
    </tbody>            
    {% endfor -%}
{%- endfor -%}
    </table>
<h2>Cash available (US$): {{ cash }}</h2>
<h2>Total portfolio value (US$): {{ wealth }}</h2>    

{% endblock %}

Result

However, I would like to get this Desired result

1

Basic problem is <table> and <thead> tags inside the first loop. Ditto <tbody> tag inside the second loop. And missing <tr></tr> tags. The "heading" HTML should look something like this:

<thead><th><td>STOCK</td><td>PRICE</td><td>SHARES</td><td>VALUE<td></th></thead>

There's a great tool to validate your HTML that could help you track down problems like this. It was included in the 2015 pset spec, but I do not see it mentioned in the current version.

Be sure, incidentally, that any HTML generated by register.php is valid, as by ctrl- or right-clicking on the page in Chrome, selecting View Page Source, highlighting and copying the source code, and then pasting it into the W3C’s validator at http://validator.w3.org/#validate_by_input and then clicking Check. Ultimately, the Result of checking your page for validity via the W3C’s validator should be Passed or Tentatively passed, in which case you should see a friendly green banner. Warnings are okay. Errors (and big red banners) are not. Note that you won’t be able to "validate by URI" at http://validator.w3.org/#validate_by_uri, since your workspace isn’t accessible on the public Internet!

FWIW here is the MDN Doc on <table> element.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .