vessel/doc/temple-example/templates/dashboard.lpt
2025-06-25 15:44:28 +03:00

94 lines
2.6 KiB
Text

{# assuming you passed a hashmap #}
{% import "base.lpt" %}
{% import "macros.lpt" : m %}
{% block title %}{{ title }} - Dashboard{% end %}
{% block header %}
<h2>{{ m.list_items([user.profile.name, user.profile.age], 1) }}</h2>
<p>Theme: {{ user.settings.theme }}</p>
{% end %}
{% block content %}
<h3>Statistics</h3>
{% for entry : stats %}
<div class="stat-group">
<h4>{{ capitalize(entry.key) }}</h4>
{% if isiter(entry.value) %}
{{ m.list_items(entry.value, 2) }}
{% else %}
<p>{{ entry.value }}</p>
{% end %}
{# Nested condition to inspect nested revenue.monthly #}
{% if period == "revenue" && stats["revenue"]["monthly"] %}
<table>
{% for month : stats.revenue.monthly %}
{{ m.table_row(month.key, month.value) }}
{% end %}
</table>
{% end %}
</div>
{% end %}
<h3>Catalog</h3>
{% for category : catalog %}
<section>
<h4>{{ category["category"] }}</h4>
{% for item : category["items"] %}
<div class="item">
<strong>{{ capitalize(item["name"]) }}</strong>
{% if item["price"] > 1.0 %}
<span>(Premium)</span>
{% else %}
<span>(Standard)</span>
{% end %}
<p>Tags:
{%
set tags = [
item.price < 1.0 ? "cheap" : "expensive",
"in stock"
]
%}
{{ m.list_items(tags, 1) }}
</p>
</div>
{% end %}
</section>
{% end %}
<h3>Messages</h3>
{% for msg : messages %}
<div class="msg">
{{ m.table_row("From", msg["from"]) }}
<p>Text: {{ escape(msg["text"]) }}</p>
{% if msg["flags"] %}
<p>Flags:</p>
{{ m.list_items(msg["flags"], 1) }}
{% end %}
</div>
{% end %}
<h3>Deep Nested Numbers</h3>
{% set matrix = [[1,2],[3,4],[5,6]] %}
{% for row : enumerate(matrix) %}
<div>
Row {{ row.index }}:
{% for num : row.value %}
{% for bit : 0:1 %}
{{ f"{num}-{bit}" }}{% if bit != 1 %}, {% end %}
{% end %}
{% end %}
</div>
{% end %}
{% end %}