If there are no records in my portfolio, I do not want to show the table in index.html
So, I tried as a parameter to pass a variable empty with value to index.html, where it was checked {% if {{ empty }} == "False" %}
Pseudo-code:
if no records:
return render_template("index.html", empty = "True", cash_current = usd(cash_current[0]['cash']), grand_total = usd(grand_total))
if records:
return render_template("index.html", empty = "False", stocks = stock_info, cash_current = usd(cash_current[0]['cash']), grand_total = usd(grand_total))
I tried the code below but unsuccessfully
{% block main %}
{% if {{ empty }} == "False" %}
<table>
<tr>
<th>Symbol</th>
<th>Name</th>
<th>Shares</th>
<th>Price</th>
<th>TOTAL</th>
</tr>
{% for stock in stocks %}
<tr>
<td> {{ stock.symbol }} </td>
<td> {{ stock.name }} </td>
<td> {{ stock.quantity }} </td>
<td> {{ stock.price }} </td>
<td> {{ stock.total }} </td>
</tr>
{% endfor %}
</table>
{% endif %}
{% endblock %}
The main idea is that if there are no records in portfolio, do not display table headings
How is it possible to implement this idea?
Any help is greatly appreciated ;)
Thanks!