Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling auto-formatting on code view #66

Open
duoi opened this issue Apr 23, 2019 · 0 comments
Open

Disabling auto-formatting on code view #66

duoi opened this issue Apr 23, 2019 · 0 comments

Comments

@duoi
Copy link

duoi commented Apr 23, 2019

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:

  1. ({{)(.*)(}}) (i.e {{ foo }})
  2. ({% for)(.*)(endfor %}) (i.e {% for i in x %} foo {% endfor %})
  3. ({% if)(.*)(endif %}) (i.e {% if bar %} foo {% else %} foobar {% endif %})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant