Add new variable dangerouslyDisableAutoEscaping

This commit is contained in:
rejas 2021-12-21 13:31:39 +01:00
parent 19bb2a0238
commit 1996efb183
2 changed files with 17 additions and 8 deletions

View File

@ -37,7 +37,8 @@ Module.register("newsfeed", {
endTags: [], endTags: [],
prohibitedWords: [], prohibitedWords: [],
scrollLength: 500, scrollLength: 500,
logFeedWarnings: false logFeedWarnings: false,
dangerouslyDisableAutoEscaping: false
}, },
// Define required scripts. // Define required scripts.

View File

@ -1,3 +1,11 @@
{% macro escapeText(text, dangerouslyDisableAutoEscaping=false) %}
{% if dangerouslyDisableAutoEscaping %}
{{ text | safe}}
{% else %}
{{ text }}
{% endif %}
{% endmacro %}
{% if loaded %} {% if loaded %}
{% if config.showAsList %} {% if config.showAsList %}
<ul class="newsfeed-list"> <ul class="newsfeed-list">
@ -14,14 +22,14 @@
</div> </div>
{% endif %} {% endif %}
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}"> <div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
{{ item.title }} {{ escapeText(item.title, config.dangerouslyDisableAutoEscaping) }}
</div> </div>
{% if config.showDescription %} {% if config.showDescription %}
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}"> <div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
{% if config.truncDescription %} {% if config.truncDescription %}
{{ item.description | truncate(config.lengthDescription) }} {{ escapeText(item.description | truncate(config.lengthDescription), config.dangerouslyDisableAutoEscaping) }}
{% else %} {% else %}
{{ item.description }} {{ escapeText(item.description, config.dangerouslyDisableAutoEscaping) }}
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
@ -33,7 +41,7 @@
{% if (config.showSourceTitle and sourceTitle) or config.showPublishDate %} {% if (config.showSourceTitle and sourceTitle) or config.showPublishDate %}
<div class="newsfeed-source light small dimmed"> <div class="newsfeed-source light small dimmed">
{% if sourceTitle and config.showSourceTitle %} {% if sourceTitle and config.showSourceTitle %}
{{ sourceTitle | safe }}{% if config.showPublishDate %}, {% else %}: {% endif %} {{ escapeText(sourceTitle, config.dangerouslyDisableAutoEscaping) }}{% if config.showPublishDate %}, {% else %}: {% endif %}
{% endif %} {% endif %}
{% if config.showPublishDate %} {% if config.showPublishDate %}
{{ publishDate }}: {{ publishDate }}:
@ -41,14 +49,14 @@
</div> </div>
{% endif %} {% endif %}
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}"> <div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
{{ title }} {{ escapeText(title, config.dangerouslyDisableAutoEscaping) }}
</div> </div>
{% if config.showDescription %} {% if config.showDescription %}
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}"> <div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
{% if config.truncDescription %} {% if config.truncDescription %}
{{ description | truncate(config.lengthDescription) | safe }} {{ escapeText(description | truncate(config.lengthDescription), config.dangerouslyDisableAutoEscaping) }}
{% else %} {% else %}
{{ description | safe }} {{ escapeText(description, config.dangerouslyDisableAutoEscaping) }}
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}