django-froala-editor
django-froala-editor copied to clipboard
Disabling auto-formatting on `code` view
Hello,
Froala doesn't seem to handle django/jinga template tags too well. For example, it automagically wraps for loops (i.e {% for i in y %}) in paragraph tags.
This is frustrating but somewhat manageable, however the real issue comes in when dealing with tables. If I have a for loop that sits outside of a tag inside a table, it would take it and append it into single string paragraph at the top.
For example,
<table>
<tr>
{% for user in users %}
<td>{{ user.first_name }}</td>
{% endfor %}
</tr>
</table>
Would become
<p>{% for user in users %} {% endfor %}</p>
<table>
<tr>
<td>{{ user.first_name }}</td>
</tr>
</table>
Even if I'm entering it view the "code" view. This of course makes it unusable for this purpose.
Is there a way to disable formatting, at least when entering things via the "code" view? Or a way to make {{ foo }} and {% bar %} exempt from auto-formatting?
Forgive my horrible regex, but I'd like to spare the following three inputs from autoformatting:
({{)(.*)(}})(i.e{{ foo }})({% for)(.*)(endfor %})(i.e{% for i in x %} foo {% endfor %})({% if)(.*)(endif %})(i.e{% if bar %} foo {% else %} foobar {% endif %})