mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 08:40:00 +00:00
Render markdown text field manually in the template
We need to escape newlines in the editor as well!
This commit is contained in:
parent
505b4e18bd
commit
f4fb9fc065
|
@ -50,7 +50,25 @@
|
|||
</ul>
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane active" id="{{ field_name }}-tab" data-markdown-target="#{{ field_name }}-markdown-target">
|
||||
{{ render_field(field, False, class_='form-control markdown-source') }}
|
||||
{# Render this field manually, because we need to escape the inner text #}
|
||||
<textarea class="form-control markdown-source" id="{{ field.id }}" name="{{ field.name }}">
|
||||
{{- field.data | escape | replace('\r\n', '\n') | replace('\n', ' '|safe) -}}
|
||||
</textarea>
|
||||
{% if field.errors %}
|
||||
<div class="help-block">
|
||||
{% if field.errors|length < 2 %}
|
||||
{% for error in field.errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<ul>
|
||||
{% for error in field.errors %}
|
||||
<li>{{ error }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="{{ field_name }}-preview">
|
||||
<div class="well" id="{{ field_name }}-markdown-target"></div>
|
||||
|
|
Loading…
Reference in a new issue