修复 Jinja2 模板 dict 访问方式和条件表达式
This commit is contained in:
@@ -97,7 +97,7 @@ def _runway_pairs(city_weather: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|||||||
result = []
|
result = []
|
||||||
for (r1, r2), (t, _d) in zip(pairs, temps):
|
for (r1, r2), (t, _d) in zip(pairs, temps):
|
||||||
if t is not None:
|
if t is not None:
|
||||||
result.append({"label": f"{r1}/{r2}", "temp": round(t, 1)})
|
result.append({"label": f"{r1}/{r2}", "temp": round(float(t), 1)})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _build_city_card(city: str, city_weather: Dict[str, Any], cfg: Dict[str, Any]) -> Dict[str, Any]:
|
def _build_city_card(city: str, city_weather: Dict[str, Any], cfg: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
|||||||
@@ -67,10 +67,8 @@ body{background:#0f1117;color:#c8cdd4;font-family:-apple-system,BlinkMacSystemFo
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{% if full_page or not full_page %}
|
|
||||||
<div id="card-grid" class="card-grid"
|
<div id="card-grid" class="card-grid"
|
||||||
hx-get="/m/cards" hx-trigger="every 30s" hx-swap="outerHTML" hx-indicator="#spinner">
|
hx-get="/m/cards" hx-trigger="every 30s" hx-swap="outerHTML" hx-indicator="#spinner">
|
||||||
{% endif %}
|
|
||||||
<span class="updated" style="display:block;grid-column:1/-1;text-align:right;margin-bottom:2px">{{ generated_at }}</span>
|
<span class="updated" style="display:block;grid-column:1/-1;text-align:right;margin-bottom:2px">{{ generated_at }}</span>
|
||||||
{% for c in cities %}
|
{% for c in cities %}
|
||||||
<div class="card{% if c.new_high %} new-high-card{% endif %}" data-new-high="{{ c.new_high | lower }}">
|
<div class="card{% if c.new_high %} new-high-card{% endif %}" data-new-high="{{ c.new_high | lower }}">
|
||||||
@@ -119,8 +117,8 @@ body{background:#0f1117;color:#c8cdd4;font-family:-apple-system,BlinkMacSystemFo
|
|||||||
<div class="runway-divider"></div>
|
<div class="runway-divider"></div>
|
||||||
{% for rw in c.runway_pairs %}
|
{% for rw in c.runway_pairs %}
|
||||||
<div class="runway-row">
|
<div class="runway-row">
|
||||||
<span class="runway-label">{{ rw.label }}</span>
|
<span class="runway-label">{{ rw["label"] }}</span>
|
||||||
<span class="runway-temp">{{ "%.1f"|format(rw.temp) }}°C</span>
|
<span class="runway-temp">{{ "%.1f"|format(rw["temp"]) }}°C</span>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user