Add Prettier plugin for Nunjuck templates (#3887)

This commit is contained in:
Veeck
2025-09-11 13:10:53 +02:00
committed by GitHub
parent 3260b9dfe4
commit 08d29c3083
13 changed files with 325 additions and 323 deletions

View File

@@ -18,6 +18,7 @@ Thanks to: @dathbe.
### Added ### Added
- Added configuration option for `User-Agent`, used by calendar & news module (#3255) - Added configuration option for `User-Agent`, used by calendar & news module (#3255)
- [linter] Added prettier plugin for nunjuck templates (#3887)
### Changed ### Changed
@@ -308,7 +309,7 @@ For more info, please read the following post: [A New Chapter for MagicMirror: T
### Added ### Added
- Output of system information to the console for troubleshooting (#3328 and #3337), ignore errors under aarch64 (#3349) - Output of system information to the console for troubleshooting (#3328 and #3337), ignore errors under aarch64 (#3349)
- [core] Add `eslint-plugin-package-json` to lint the `package.json` files (#3368) - [linter] Add `eslint-plugin-package-json` to lint the `package.json` files (#3368)
- [weather] `showHumidity` config is now a string describing where to show this element. Supported values: "wind", "temp", "feelslike", "below", "none". (#3330) - [weather] `showHumidity` config is now a string describing where to show this element. Supported values: "wind", "temp", "feelslike", "below", "none". (#3330)
- electron-rebuild test suite for electron and 3rd party modules compatibility (#3392) - electron-rebuild test suite for electron and 3rd party modules compatibility (#3392)
- Create MM² icon and attach it to electron process (#3407) - Create MM² icon and attach it to electron process (#3407)
@@ -470,7 +471,7 @@ Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not al
- Added UV Index to hourly and current Weather, with support for Openmeteo - Added UV Index to hourly and current Weather, with support for Openmeteo
- Added tests for serveronly - Added tests for serveronly
- Set Timezone `Europe/Berlin` in unit tests (needed for new formatTime tests) - Set Timezone `Europe/Berlin` in unit tests (needed for new formatTime tests)
- Added no-param-reassign eslint rule and fix warnings - [linter] Added no-param-reassign eslint rule and fix warnings
- [updatenotification] Added `sendUpdatesNotifications` feature. Broadcast update with `UPDATES` notification to other modules - [updatenotification] Added `sendUpdatesNotifications` feature. Broadcast update with `UPDATES` notification to other modules
- [updatenotification] Allow force scanning with `SCAN_UPDATES` notification from other modules - [updatenotification] Allow force scanning with `SCAN_UPDATES` notification from other modules
- Added per-calendar fetchInterval - Added per-calendar fetchInterval

View File

@@ -1,20 +1,20 @@
{% if imageUrl or imageFA %} {% if imageUrl or imageFA %}
{% set imageHeight = imageHeight if imageHeight else "80px" %} {% set imageHeight = imageHeight if imageHeight else "80px" %}
{% if imageUrl %} {% if imageUrl %}
<img src="{{ imageUrl }}" <img src="{{ imageUrl }}" height="{{ imageHeight }}" style="margin-bottom: 10px" />
height="{{ imageHeight }}" {% else %}
style="margin-bottom: 10px" /> <span
{% else %} class="bright fas fa-{{ imageFA }}"
<span class="bright fas fa-{{ imageFA }}" style="margin-bottom: 10px;
style="margin-bottom: 10px; font-size: {{ imageHeight }}"
font-size: {{ imageHeight }}"></span> ></span>
{% endif %} {% endif %}
<br /> <br />
{% endif %} {% endif %}
{% if title %} {% if title %}
<span class="thin dimmed medium">{{ title if titleType == 'text' else title | safe }}</span> <span class="thin dimmed medium">{{ title if titleType == 'text' else title | safe }}</span>
{% endif %} {% endif %}
{% if message %} {% if message %}
{% if title %}<br />{% endif %} {% if title %}<br />{% endif %}
<span class="light bright small">{{ message if messageType == 'text' else message | safe }}</span> <span class="light bright small">{{ message if messageType == 'text' else message | safe }}</span>
{% endif %} {% endif %}

View File

@@ -1,7 +1,7 @@
{% if title %} {% if title %}
<span class="thin dimmed medium">{{ title if titleType == 'text' else title | safe }}</span> <span class="thin dimmed medium">{{ title if titleType == 'text' else title | safe }}</span>
{% endif %} {% endif %}
{% if message %} {% if message %}
{% if title %}<br />{% endif %} {% if title %}<br />{% endif %}
<span class="light bright small">{{ message if messageType == 'text' else message | safe }}</span> <span class="light bright small">{{ message if messageType == 'text' else message | safe }}</span>
{% endif %} {% endif %}

View File

@@ -1,3 +1,3 @@
<div> <div>
<iframe class="newsfeed-fullarticle" src="{{ url }}"></iframe> <iframe class="newsfeed-fullarticle" src="{{ url }}"></iframe>
</div> </div>

View File

@@ -1,89 +1,89 @@
{% macro escapeText(text, dangerouslyDisableAutoEscaping=false) %} {% macro escapeText(text, dangerouslyDisableAutoEscaping=false) %}
{% if dangerouslyDisableAutoEscaping -%} {% if dangerouslyDisableAutoEscaping -%}
{{ text | safe }} {{ text | safe }}
{%- else -%} {%- else -%}
{{ text }} {{ text }}
{%- endif %} {%- endif %}
{% endmacro %} {% endmacro %}
{% macro escapeTitle(title, url, dangerouslyDisableAutoEscaping=false, showTitleAsUrl=false) %} {% macro escapeTitle(title, url, dangerouslyDisableAutoEscaping=false, showTitleAsUrl=false) %}
{% if dangerouslyDisableAutoEscaping %} {% if dangerouslyDisableAutoEscaping %}
{% if showTitleAsUrl %} {% if showTitleAsUrl %}
<a href="{{ url }}" <a
style="text-decoration:none; href="{{ url }}"
style="text-decoration:none;
color:#ffffff" color:#ffffff"
target="_blank">{{ title | safe }}</a> target="_blank"
{% else %} >{{ title | safe }}</a
{{ title | safe }} >
{% endif %}
{% else %} {% else %}
{% if showTitleAsUrl %} {{ title | safe }}
<a href="{{ url }}"
style="text-decoration:none;
color:#ffffff"
target="_blank">{{ title }}</a>
{% else %}
{{ title }}
{% endif %}
{% endif %} {% endif %}
{% else %}
{% if showTitleAsUrl %}
<a
href="{{ url }}"
style="text-decoration:none;
color:#ffffff"
target="_blank"
>{{ title }}</a
>
{% else %}
{{ title }}
{% endif %}
{% endif %}
{% endmacro %} {% endmacro %}
{% if loaded %} {% if loaded %}
{% if config.showAsList %} {% if config.showAsList %}
<ul class="newsfeed-list"> <ul class="newsfeed-list">
{% for item in items %} {% for item in items %}
<li> <li>
{% if (config.showSourceTitle and item.sourceTitle) or config.showPublishDate %} {% if (config.showSourceTitle and item.sourceTitle) or config.showPublishDate %}
<div class="newsfeed-source light small dimmed"> <div class="newsfeed-source light small dimmed">
{% if item.sourceTitle and config.showSourceTitle %} {% if item.sourceTitle and config.showSourceTitle %}
{{ item.sourceTitle }}{% if config.showPublishDate %}, {% else %}:{% endif %} {{ item.sourceTitle }}{% if config.showPublishDate %},{% else %}:{% endif %}
{% endif %} {% endif %}
{% if config.showPublishDate %}{{ item.publishDate }}:{% endif %} {% if config.showPublishDate %}{{ item.publishDate }}:{% endif %}
</div>
{% endif %}
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
{{ escapeTitle(item.title, item.url, config.dangerouslyDisableAutoEscaping, config.showTitleAsUrl) }}
</div>
{% if config.showDescription %}
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
{% if config.truncDescription %}
{{ escapeText(item.description | truncate(config.lengthDescription) , config.dangerouslyDisableAutoEscaping) }}
{% else %}
{{ escapeText(item.description, config.dangerouslyDisableAutoEscaping) }}
{% endif %}
</div>
{% endif %}
</li>
{% endfor %}
</ul>
{% else %}
<div>
{% if (config.showSourceTitle and sourceTitle) or config.showPublishDate %}
<div class="newsfeed-source light small dimmed">
{% if sourceTitle and config.showSourceTitle %}
{{ escapeText(sourceTitle, config.dangerouslyDisableAutoEscaping) }}{% if config.showPublishDate %}, {% else %}:{% endif %}
{% endif %}
{% if config.showPublishDate %}{{ publishDate }}:{% endif %}
</div>
{% endif %}
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
{{ escapeTitle(title, url, config.dangerouslyDisableAutoEscaping, config.showTitleAsUrl) }}
</div> </div>
{% if config.showDescription %} {% endif %}
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}"> <div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">{{ escapeTitle(item.title, item.url, config.dangerouslyDisableAutoEscaping, config.showTitleAsUrl) }}</div>
{% if config.truncDescription %} {% if config.showDescription %}
{{ escapeText(description | truncate(config.lengthDescription) , config.dangerouslyDisableAutoEscaping) }} <div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
{% else %} {% if config.truncDescription %}
{{ escapeText(description, config.dangerouslyDisableAutoEscaping) }} {{ escapeText(item.description | truncate(config.lengthDescription) , config.dangerouslyDisableAutoEscaping) }}
{% endif %} {% else %}
</div> {{ escapeText(item.description, config.dangerouslyDisableAutoEscaping) }}
{% endif %} {% endif %}
</div>
{% endif %}
</li>
{% endfor %}
</ul>
{% else %}
<div>
{% if (config.showSourceTitle and sourceTitle) or config.showPublishDate %}
<div class="newsfeed-source light small dimmed">
{% if sourceTitle and config.showSourceTitle %}
{{ escapeText(sourceTitle, config.dangerouslyDisableAutoEscaping) }}{% if config.showPublishDate %},{% else %}:{% endif %}
{% endif %}
{% if config.showPublishDate %}{{ publishDate }}:{% endif %}
</div> </div>
{% endif %} {% endif %}
{% elseif empty %} <div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">{{ escapeTitle(title, url, config.dangerouslyDisableAutoEscaping, config.showTitleAsUrl) }}</div>
<div class="small dimmed">{{ "NEWSFEED_NO_ITEMS" | translate | safe }}</div> {% if config.showDescription %}
{% elseif error %} <div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
<div class="small dimmed"> {% if config.truncDescription %}
{{ "MODULE_CONFIG_ERROR" | translate({MODULE_NAME: "Newsfeed", ERROR: error}) | safe }} {{ escapeText(description | truncate(config.lengthDescription) , config.dangerouslyDisableAutoEscaping) }}
{% else %}
{{ escapeText(description, config.dangerouslyDisableAutoEscaping) }}
{% endif %}
</div>
{% endif %}
</div> </div>
{% endif %}
{% elseif empty %}
<div class="small dimmed">{{ "NEWSFEED_NO_ITEMS" | translate | safe }}</div>
{% elseif error %}
<div class="small dimmed">{{ "MODULE_CONFIG_ERROR" | translate({MODULE_NAME: "Newsfeed", ERROR: error}) | safe }}</div>
{% else %} {% else %}
<div class="small dimmed">{{ "LOADING" | translate | safe }}</div> <div class="small dimmed">{{ "LOADING" | translate | safe }}</div>
{% endif %} {% endif %}

View File

@@ -1,3 +1 @@
<div class="small bright"> <div class="small bright">{{ "MODULE_CONFIG_CHANGED" | translate({MODULE_NAME: "Newsfeed"}) | safe }}</div>
{{ "MODULE_CONFIG_CHANGED" | translate({MODULE_NAME: "Newsfeed"}) | safe }}
</div>

View File

@@ -1,41 +1,41 @@
{% if not suspended %} {% if not suspended %}
{% if needRestart %} {% if needRestart %}
<div class="small bright"> <div class="small bright">
<i class="fas fa-rotate"></i> <i class="fas fa-rotate"></i>
<span> <span>
{% set restartTextLabel = "UPDATE_NOTIFICATION_NEED-RESTART" %} {% set restartTextLabel = "UPDATE_NOTIFICATION_NEED-RESTART" %}
{{ restartTextLabel | translate() | safe }} {{ restartTextLabel | translate() | safe }}
</span> </span>
</div> </div>
{% endif %} {% endif %}
{% for name, status in moduleList %} {% for name, status in moduleList %}
<div class="small bright"> <div class="small bright">
<i class="fas fa-exclamation-circle"></i> <i class="fas fa-exclamation-circle"></i>
<span> <span>
{% set mainTextLabel = "UPDATE_NOTIFICATION" if name === "MagicMirror" else "UPDATE_NOTIFICATION_MODULE" %} {% set mainTextLabel = "UPDATE_NOTIFICATION" if name === "MagicMirror" else "UPDATE_NOTIFICATION_MODULE" %}
{{ mainTextLabel | translate({MODULE_NAME: name}) }} {{ mainTextLabel | translate({MODULE_NAME: name}) }}
</span> </span>
</div> </div>
<div class="xsmall dimmed"> <div class="xsmall dimmed">
{% set subTextLabel = "UPDATE_INFO_SINGLE" if status.behind === 1 else "UPDATE_INFO_MULTIPLE" %} {% set subTextLabel = "UPDATE_INFO_SINGLE" if status.behind === 1 else "UPDATE_INFO_MULTIPLE" %}
{{ subTextLabel | translate({COMMIT_COUNT: status.behind, BRANCH_NAME: status.current}) | diffLink(status) | safe }} {{ subTextLabel | translate({COMMIT_COUNT: status.behind, BRANCH_NAME: status.current}) | diffLink(status) | safe }}
</div> </div>
{% endfor %} {% endfor %}
{% for name, status in updatesList %} {% for name, status in updatesList %}
<div class="small bright"> <div class="small bright">
{% if status.done %} {% if status.done %}
<i class="fas fa-check" style="color: lightgreen;"></i> <i class="fas fa-check" style="color: lightgreen;"></i>
<span> <span>
{% set updateTextLabel = "UPDATE_NOTIFICATION_DONE" %} {% set updateTextLabel = "UPDATE_NOTIFICATION_DONE" %}
{{ updateTextLabel | translate({MODULE_NAME: name}) | safe }} {{ updateTextLabel | translate({MODULE_NAME: name}) | safe }}
</span> </span>
{% else %} {% else %}
<i class="fas fa-xmark" style="color: red;"></i> <i class="fas fa-xmark" style="color: red;"></i>
<span> <span>
{% set updateTextLabel = "UPDATE_NOTIFICATION_ERROR" %} {% set updateTextLabel = "UPDATE_NOTIFICATION_ERROR" %}
{{ updateTextLabel | translate({MODULE_NAME: name}) | safe }} {{ updateTextLabel | translate({MODULE_NAME: name}) | safe }}
</span> </span>
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}
{% endif %} {% endif %}

View File

@@ -1,101 +1,95 @@
{% macro humidity() %} {% macro humidity() %}
{% if current.humidity %} {% if current.humidity %}
<span class="humidity"><span>{{ current.humidity | decimalSymbol }}</span><sup>&nbsp;<i class="wi wi-humidity humidity-icon"></i></sup></span> <span class="humidity"
{% endif %} ><span>{{ current.humidity | decimalSymbol }}</span><sup>&nbsp;<i class="wi wi-humidity humidity-icon"></i></sup
></span>
{% endif %}
{% endmacro %} {% endmacro %}
{% if current %} {% if current %}
{% if not config.onlyTemp %} {% if not config.onlyTemp %}
<div class="normal medium"> <div class="normal medium">
<span class="wi wi-strong-wind dimmed"></span> <span class="wi wi-strong-wind dimmed"></span>
<span> <span>
{{ current.windSpeed | unit("wind") | round }} {{ current.windSpeed | unit("wind") | round }}
{% if config.showWindDirection %} {% if config.showWindDirection %}
<sup> <sup>
{% if config.showWindDirectionAsArrow %} {% if config.showWindDirectionAsArrow %}
<i class="fas fa-long-arrow-alt-down" style="transform:rotate({{ current.windFromDirection }}deg)"></i> <i class="fas fa-long-arrow-alt-down" style="transform:rotate({{ current.windFromDirection }}deg)"></i>
{% else %} {% else %}
{{ current.cardinalWindDirection() | translate }} {{ current.cardinalWindDirection() | translate }}
{% endif %}
&nbsp;
</sup>
{% endif %}
</span>
{% if config.showHumidity === "wind" %}
{{ humidity() }}
{% endif %} {% endif %}
{% if config.showSun %} &nbsp;
<span class="wi dimmed wi-{{ current.nextSunAction() }}"></span> </sup>
<span>
{% if current.nextSunAction() === "sunset" %}
{{ current.sunset | formatTime }}
{% else %}
{{ current.sunrise | formatTime }}
{% endif %}
</span>
{% endif %}
{% if config.showUVIndex %}
<td class="align-right bright uv-index">
<div class="wi dimmed wi-hot"></div>
{{ current.uv_index }}
</td>
{% endif %}
</div>
{% endif %}
<div class="large">
{% if config.showIndoorTemperature and indoor.temperature or config.showIndoorHumidity and indoor.humidity %}
<span class="medium fas fa-home"></span>
<span style="display: inline-block">
{% if config.showIndoorTemperature and indoor.temperature %}
<sup class="small" style="position: relative; display: block; text-align: left;">
<span>
{{ indoor.temperature | roundValue | unit("temperature") | decimalSymbol }}
</span>
</sup>
{% endif %}
{% if config.showIndoorHumidity and indoor.humidity %}
<sub class="small" style="position: relative; display: block; text-align: left;">
<span>
{{ indoor.humidity | roundValue | unit("humidity") | decimalSymbol }}
</span>
</sub>
{% endif %}
</span>
{% endif %}
<span class="light wi weathericon wi-{{ current.weatherType }}"></span>
<span class="light bright">{{ current.temperature | roundValue | unit("temperature") | decimalSymbol }}</span>
{% if config.showHumidity === "temp" %}
<span class="medium bright">{{ humidity() }}</span>
{% endif %} {% endif %}
</span>
{% if config.showHumidity === "wind" %}
{{ humidity() }}
{% endif %}
{% if config.showSun %}
<span class="wi dimmed wi-{{ current.nextSunAction() }}"></span>
<span>
{% if current.nextSunAction() === "sunset" %}
{{ current.sunset | formatTime }}
{% else %}
{{ current.sunrise | formatTime }}
{% endif %}
</span>
{% endif %}
{% if config.showUVIndex %}
<td class="align-right bright uv-index">
<div class="wi dimmed wi-hot"></div>
{{ current.uv_index }}
</td>
{% endif %}
</div> </div>
{% if (config.showFeelsLike or config.showPrecipitationAmount or config.showPrecipitationProbability) and not config.onlyTemp %} {% endif %}
<div class="normal medium feelslike"> <div class="large">
{% if config.showFeelsLike %} {% if config.showIndoorTemperature and indoor.temperature or config.showIndoorHumidity and indoor.humidity %}
<span class="dimmed"> <span class="medium fas fa-home"></span>
{% if config.showHumidity === "feelslike" %} <span style="display: inline-block">
{{ humidity() }} {% if config.showIndoorTemperature and indoor.temperature %}
{% endif %} <sup class="small" style="position: relative; display: block; text-align: left;">
{{ "FEELS" | translate({DEGREE: current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }) }} <span> {{ indoor.temperature | roundValue | unit("temperature") | decimalSymbol }} </span>
</span> </sup>
<br /> {% endif %}
{% endif %} {% if config.showIndoorHumidity and indoor.humidity %}
{% if config.showPrecipitationAmount and current.precipitationAmount %} <sub class="small" style="position: relative; display: block; text-align: left;">
<span class="dimmed"> <span> {{ indoor.humidity | roundValue | unit("humidity") | decimalSymbol }} </span>
<span class="precipitationLeadText">{{ "PRECIP_AMOUNT" | translate }}</span> {{ current.precipitationAmount | unit("precip", current.precipitationUnits) }} </sub>
</span> {% endif %}
<br /> </span>
{% endif %}
{% if config.showPrecipitationProbability and current.precipitationProbability %}
<span class="dimmed">
<span class="precipitationLeadText">{{ "PRECIP_POP" | translate }}</span> {{ current.precipitationProbability }}%
</span>
{% endif %}
</div>
{% endif %} {% endif %}
{% if config.showHumidity === "below" %} <span class="light wi weathericon wi-{{ current.weatherType }}"></span>
<span class="medium dimmed">{{ humidity() }}</span> <span class="light bright">{{ current.temperature | roundValue | unit("temperature") | decimalSymbol }}</span>
{% if config.showHumidity === "temp" %}
<span class="medium bright">{{ humidity() }}</span>
{% endif %} {% endif %}
</div>
{% if (config.showFeelsLike or config.showPrecipitationAmount or config.showPrecipitationProbability) and not config.onlyTemp %}
<div class="normal medium feelslike">
{% if config.showFeelsLike %}
<span class="dimmed">
{% if config.showHumidity === "feelslike" %}
{{ humidity() }}
{% endif %}
{{ "FEELS" | translate({DEGREE: current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }) }}
</span>
<br />
{% endif %}
{% if config.showPrecipitationAmount and current.precipitationAmount %}
<span class="dimmed"> <span class="precipitationLeadText">{{ "PRECIP_AMOUNT" | translate }}</span> {{ current.precipitationAmount | unit("precip", current.precipitationUnits) }} </span>
<br />
{% endif %}
{% if config.showPrecipitationProbability and current.precipitationProbability %}
<span class="dimmed"> <span class="precipitationLeadText">{{ "PRECIP_POP" | translate }}</span> {{ current.precipitationProbability }}% </span>
{% endif %}
</div>
{% endif %}
{% if config.showHumidity === "below" %}
<span class="medium dimmed">{{ humidity() }}</span>
{% endif %}
{% else %} {% else %}
<div class="dimmed light small">{{ "LOADING" | translate }}</div> <div class="dimmed light small">{{ "LOADING" | translate }}</div>
{% endif %} {% endif %}
<!-- Uncomment the line below to see the contents of the `current` object. --> <!-- Uncomment the line below to see the contents of the `current` object. -->
<!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{current | dump}}</div> --> <!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{ current | dump }}</div> -->

View File

@@ -1,52 +1,46 @@
{% if forecast %} {% if forecast %}
{% set numSteps = forecast | calcNumSteps %} {% set numSteps = forecast | calcNumSteps %}
{% set currentStep = 0 %} {% set currentStep = 0 %}
<table class="{{ config.tableClass }}"> <table class="{{ config.tableClass }}">
{% if config.ignoreToday %} {% if config.ignoreToday %}
{% set forecast = forecast.splice(1) %} {% set forecast = forecast.splice(1) %}
{% endif %}
{% set forecast = forecast.slice(0, numSteps) %}
{% for f in forecast %}
<tr
{% if config.colored %}class="colored"{% endif %}
{% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}
>
{% if (currentStep == 0) and config.ignoreToday == false and config.absoluteDates == false %}
<td class="day">{{ "TODAY" | translate }}</td>
{% elif (currentStep == 1) and config.ignoreToday == false and config.absoluteDates == false %}
<td class="day">{{ "TOMORROW" | translate }}</td>
{% else %}
<td class="day">{{ f.date.format("ddd") }}</td>
{% endif %} {% endif %}
{% set forecast = forecast.slice(0, numSteps) %} <td class="bright weather-icon">
{% for f in forecast %} <span class="wi weathericon wi-{{ f.weatherType }}"></span>
<tr {% if config.colored %}class="colored"{% endif %} </td>
{% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}> <td class="align-right bright max-temp">{{ f.maxTemperature | roundValue | unit("temperature") | decimalSymbol }}</td>
{% if (currentStep == 0) and config.ignoreToday == false and config.absoluteDates == false %} <td class="align-right min-temp">{{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }}</td>
<td class="day">{{ "TODAY" | translate }}</td> {% if config.showPrecipitationAmount %}
{% elif (currentStep == 1) and config.ignoreToday == false and config.absoluteDates == false %} <td class="align-right bright precipitation-amount">{{ f.precipitationAmount | unit("precip", f.precipitationUnits) }}</td>
<td class="day">{{ "TOMORROW" | translate }}</td> {% endif %}
{% else %} {% if config.showPrecipitationProbability %}
<td class="day">{{ f.date.format("ddd") }}</td> <td class="align-right bright precipitation-prob">{{ f.precipitationProbability | unit('precip', '%') }}</td>
{% endif %} {% endif %}
<td class="bright weather-icon"> {% if config.showUVIndex %}
<span class="wi weathericon wi-{{ f.weatherType }}"></span> <td class="align-right dimmed uv-index">
</td> {{ f.uv_index }}
<td class="align-right bright max-temp"> <span class="wi dimmed weathericon wi-hot"></span>
{{ f.maxTemperature | roundValue | unit("temperature") | decimalSymbol }} </td>
</td> {% endif %}
<td class="align-right min-temp"> </tr>
{{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }} {% set currentStep = currentStep + 1 %}
</td> {% endfor %}
{% if config.showPrecipitationAmount %} </table>
<td class="align-right bright precipitation-amount">
{{ f.precipitationAmount | unit("precip", f.precipitationUnits) }}
</td>
{% endif %}
{% if config.showPrecipitationProbability %}
<td class="align-right bright precipitation-prob">
{{ f.precipitationProbability | unit('precip', '%') }}
</td>
{% endif %}
{% if config.showUVIndex %}
<td class="align-right dimmed uv-index">
{{ f.uv_index }}
<span class="wi dimmed weathericon wi-hot"></span>
</td>
{% endif %}
</tr>
{% set currentStep = currentStep + 1 %}
{% endfor %}
</table>
{% else %} {% else %}
<div class="dimmed light small">{{ "LOADING" | translate }}</div> <div class="dimmed light small">{{ "LOADING" | translate }}</div>
{% endif %} {% endif %}
<!-- Uncomment the line below to see the contents of the `forecast` object. --> <!-- Uncomment the line below to see the contents of the `forecast` object. -->
<!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{forecast | dump}}</div> --> <!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{ forecast | dump }}</div> -->

View File

@@ -1,52 +1,48 @@
{% if hourly %} {% if hourly %}
{% set numSteps = hourly | calcNumEntries %} {% set numSteps = hourly | calcNumEntries %}
{% set currentStep = 0 %} {% set currentStep = 0 %}
<table class="{{ config.tableClass }}"> <table class="{{ config.tableClass }}">
{% set hours = hourly.slice(0, numSteps) %} {% set hours = hourly.slice(0, numSteps) %}
{% for hour in hours %} {% for hour in hours %}
<tr {% if config.colored %}class="colored"{% endif %} <tr
{% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}> {% if config.colored %}class="colored"{% endif %}
<td class="day">{{ hour.date | formatTime }}</td> {% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}
<td class="bright weather-icon"> >
<span class="wi weathericon wi-{{ hour.weatherType }}"></span> <td class="day">{{ hour.date | formatTime }}</td>
</td> <td class="bright weather-icon">
<td class="align-right bright"> <span class="wi weathericon wi-{{ hour.weatherType }}"></span>
{{ hour.temperature | roundValue | unit("temperature") }} </td>
</td> <td class="align-right bright">{{ hour.temperature | roundValue | unit("temperature") }}</td>
{% if config.showUVIndex %} {% if config.showUVIndex %}
<td class="align-right bright uv-index"> <td class="align-right bright uv-index">
{% if hour.uv_index!=0 %} {% if hour.uv_index!=0 %}
{{ hour.uv_index }} {{ hour.uv_index }}
<span class="wi weathericon wi-hot"></span> <span class="wi weathericon wi-hot"></span>
{% endif %} {% endif %}
</td> </td>
{% endif %} {% endif %}
{% if config.showHumidity != "none" %} {% if config.showHumidity != "none" %}
<td class="align-left bright humidity-hourly"> <td class="align-left bright humidity-hourly">
{{ hour.humidity }} {{ hour.humidity }}
<span class="wi wi-humidity humidity-icon"></span> <span class="wi wi-humidity humidity-icon"></span>
</td> </td>
{% endif %} {% endif %}
{% if config.showPrecipitationAmount %} {% if config.showPrecipitationAmount %}
{% if (not config.hideZeroes or hour.precipitationAmount>0) %} {% if (not config.hideZeroes or hour.precipitationAmount>0) %}
<td class="align-right bright precipitation-amount"> <td class="align-right bright precipitation-amount">{{ hour.precipitationAmount | unit("precip", hour.precipitationUnits) }}</td>
{{ hour.precipitationAmount | unit("precip", hour.precipitationUnits) }} {% endif %}
</td> {% endif %}
{% endif %} {% if config.showPrecipitationProbability %}
{% endif %} {% if (not config.hideZeroes or hour.precipitationAmount>0) %}
{% if config.showPrecipitationProbability %} <td class="align-right bright precipitation-prob">{{ hour.precipitationProbability | unit('precip', '%') }}</td>
{% if (not config.hideZeroes or hour.precipitationAmount>0) %} {% endif %}
<td class="align-right bright precipitation-prob"> {% endif %}
{{ hour.precipitationProbability | unit('precip', '%') }} </tr>
</td> {% set currentStep = currentStep + 1 %}
{% endif %} {% endfor %}
{% endif %} </table>
</tr>
{% set currentStep = currentStep + 1 %}
{% endfor %}
</table>
{% else %} {% else %}
<div class="dimmed light small">{{ "LOADING" | translate }}</div> <div class="dimmed light small">{{ "LOADING" | translate }}</div>
{% endif %} {% endif %}
<!-- Uncomment the line below to see the contents of the `hourly` object. --> <!-- Uncomment the line below to see the contents of the `hourly` object. -->
<!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{hourly | dump}}</div> --> <!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{ hourly | dump }}</div> -->

11
package-lock.json generated
View File

@@ -52,6 +52,7 @@
"markdownlint-cli2": "^0.18.1", "markdownlint-cli2": "^0.18.1",
"playwright": "^1.55.0", "playwright": "^1.55.0",
"prettier": "^3.6.2", "prettier": "^3.6.2",
"prettier-plugin-jinja-template": "^2.1.0",
"stylelint": "^16.24.0", "stylelint": "^16.24.0",
"stylelint-config-standard": "^39.0.0", "stylelint-config-standard": "^39.0.0",
"stylelint-prettier": "^5.0.3" "stylelint-prettier": "^5.0.3"
@@ -11763,6 +11764,16 @@
"node": ">=6.0.0" "node": ">=6.0.0"
} }
}, },
"node_modules/prettier-plugin-jinja-template": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/prettier-plugin-jinja-template/-/prettier-plugin-jinja-template-2.1.0.tgz",
"integrity": "sha512-mzoCp2Oy9BDSug80fw3B3J4n4KQj1hRvoQOL1akqcDKBb5nvYxrik9zUEDs4AEJ6nK7QDTGoH0y9rx7AlnQ78Q==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"prettier": "^3.0.0"
}
},
"node_modules/pretty-format": { "node_modules/pretty-format": {
"version": "30.0.5", "version": "30.0.5",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.0.5.tgz", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.0.5.tgz",

View File

@@ -111,6 +111,7 @@
"markdownlint-cli2": "^0.18.1", "markdownlint-cli2": "^0.18.1",
"playwright": "^1.55.0", "playwright": "^1.55.0",
"prettier": "^3.6.2", "prettier": "^3.6.2",
"prettier-plugin-jinja-template": "^2.1.0",
"stylelint": "^16.24.0", "stylelint": "^16.24.0",
"stylelint-config-standard": "^39.0.0", "stylelint-config-standard": "^39.0.0",
"stylelint-prettier": "^5.0.3" "stylelint-prettier": "^5.0.3"

View File

@@ -1,10 +1,17 @@
const config = { const config = {
plugins: ["prettier-plugin-jinja-template"],
overrides: [ overrides: [
{ {
files: "*.md", files: "*.md",
options: { options: {
parser: "markdown" parser: "markdown"
} }
},
{
files: ["*.njk"],
options: {
parser: "jinja-template"
}
} }
], ],
trailingComma: "none" trailingComma: "none"