mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: template: use builtin nl2br
This commit is contained in:
1 parent
dc7d53b59c
commit
ff096322fc
3 files changed
+9
-10
No files matched your search
@@ -77,7 +77,6 @@ class Nunjucks extends nunjucks.Environment {
|
||||
this.addFilter('base64_decode', (s) => Buffer.from(s, 'base64').toString());
|
||||
this.addFilter('jsesc', (self) => jsesc(self, { isScriptContext: true }));
|
||||
this.addFilter('bitand', (self, val) => self & val);
|
||||
this.addFilter('replaceBr', (self) => self.toString().replace(/\n/g, '<br>'));
|
||||
this.addFilter('toString', (self) => (typeof self === 'string' ? self : JSON.stringify(self, replacer)));
|
||||
this.addFilter('content', (content, language, html) => {
|
||||
let s = '';
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
{{ column.value }}<br />{{ pdict[column.raw].nAccept }}/{{ pdict[column.raw].nSubmit }}
|
||||
</a>
|
||||
{% else %}
|
||||
{{ column.value|replaceBr|safe }}
|
||||
{{ column.value|nl2br|safe }}
|
||||
{% endif %}
|
||||
</th>
|
||||
{%- endfor -%}
|
||||
@@ -52,21 +52,21 @@
|
||||
{{ user.render_inline(udict[column.raw], badge=false) }}
|
||||
{% elif column.type == 'record' and column.raw %}
|
||||
<a href="{{ url('record_detail', rid=column.raw) if canView else '' }}" data-tooltip="{{ column.hover }}">
|
||||
<span style="font-weight:bold;color:{{ utils.status.getScoreColor(column.score|default(column.value)) }}">{{ column.value|replaceBr|safe }}</span>
|
||||
<span style="font-weight:bold;color:{{ utils.status.getScoreColor(column.score|default(column.value)) }}">{{ column.value|nl2br|safe }}</span>
|
||||
</a>
|
||||
{% elif column.type == 'records' %}
|
||||
{%- for record in column.raw -%}
|
||||
{% if loop.index0 %}/{% endif %}
|
||||
{% if record.raw %}
|
||||
<a href="{{ url('record_detail', rid=record.raw) if canView else '' }}">
|
||||
<span style="font-weight:bold;color:{{ utils.status.getScoreColor(record.score|default(record.value)) }}">{{ record.value|replaceBr|safe }}</span>
|
||||
<span style="font-weight:bold;color:{{ utils.status.getScoreColor(record.score|default(record.value)) }}">{{ record.value|nl2br|safe }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
{{ record.value|replaceBr|safe }}
|
||||
{{ record.value|nl2br|safe }}
|
||||
{% endif %}
|
||||
{%- endfor -%}
|
||||
{% else %}
|
||||
{{ column.value|replaceBr|safe }}
|
||||
{{ column.value|nl2br|safe }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{%- endfor -%}
|
||||
|
||||
@@ -47,21 +47,21 @@ Exported from <a href="{{ model.system.get('server.url') }}">{{ model.system.get
|
||||
<td>
|
||||
{% if column.type == 'record' and column.raw %}
|
||||
<a href="{{ model.system.get('server.url') }}{{ url('record_detail', rid=column.raw).substr(1,9999) }}">
|
||||
<span style="font-weight:bold;color:{{ utils.status.getScoreColor(column.score|default(column.value)) }}">{{ column.value|replaceBr|safe }}</span>
|
||||
<span style="font-weight:bold;color:{{ utils.status.getScoreColor(column.score|default(column.value)) }}">{{ column.value|nl2br|safe }}</span>
|
||||
</a>
|
||||
{% elif column.type == 'records' %}
|
||||
{%- for record in column.raw -%}
|
||||
{% if loop.index0 %}/{% endif %}
|
||||
{% if record.raw %}
|
||||
<a href="{{ model.system.get('server.url') }}{{ url('record_detail', rid=record.raw).substr(1,9999) }}">
|
||||
<span style="font-weight:bold;color:{{ utils.status.getScoreColor(record.score|default(record.value)) }}">{{ record.value|replaceBr|safe }}</span>
|
||||
<span style="font-weight:bold;color:{{ utils.status.getScoreColor(record.score|default(record.value)) }}">{{ record.value|nl2br|safe }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
{{ record.value|replaceBr|safe }}
|
||||
{{ record.value|nl2br|safe }}
|
||||
{% endif %}
|
||||
{%- endfor -%}
|
||||
{% else %}
|
||||
{{ column.value|replaceBr|safe }}
|
||||
{{ column.value|nl2br|safe }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{%- endfor -%}
|
||||
|
||||
Reference in new issue
Block a user