Skip to content

Conversation

@jasmith-hs
Copy link
Contributor

Allows {% cycle 'a','class=\'foo bar\'' %} to be interpreted correctly by splitting properly and not trying to split into 'a',;class=\'foo and bar\''.

Replaces calls to WhitespaceUtils.unquote with WhitespaceUtils.unquoteAndUnescape to properly unescape quoted strings.

This fixes escaping and unescaping in the following tags:

  • {% cycle %}
  • {% extends %}
  • {% from %}
  • {% import %}
  • {% include %}
  • {% block %}

Previously this would fail to render:

{% for item in [0,1] %}{% cycle 'a','class=\\'foo bar\\'' %}.{% endfor %}

And the following would render incorrectly:

{% for item in [0,1] %}{% cycle 'a','class=\\'foobar\\'' %}.{% endfor %}

Rendering as a.class=\'foobar\'. instead of a.class='foobar'.

@jasmith-hs jasmith-hs merged commit 12e2258 into master Oct 17, 2025
3 checks passed
@jasmith-hs jasmith-hs deleted the handle-escaping-and-unescaping-in-tokenizer branch October 17, 2025 20:25
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

Successfully merging this pull request may close these issues.

3 participants