-
-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
See https://github.com/posthtml/posthtml-expressions/tree/textnode-ignore for a reproduction, just run the core tests:
npx ava test/test-core.js
TL;DR the regex used to support expression ignoring seems to not work on text nodes correctly. Also, the one for ignored unescaped delimiters (i.e. @{{{ foo }}}) doesn't seem to work at all.
When you have a text node with mixed expressions {{ foo }} and ignored expressions @{{ foo }}, they are rendered incorrectly.
Given we set foo: 'bar' in locals, this is what is currently happening:
Source:
ignored: @{{ foo }}
ignoredUnescaped: @{{{ foo }}}
rendered: {{ foo }}
Expected:
+ ignored: {{ foo }}
+ ignoredUnescaped: {{{ foo }}}
+ rendered: barActual:
- ignored: @bar
- ignoredUnescaped: @{bar}
- rendered: {{ foo }}Note
This only appears to happen within text nodes, if each line is wrapped in an HTML tag then ignored and rendered are correct. ignoredUnescaped will still be wrong:
Source:
<p>ignored: @{{ foo }}</p>
<p>ignoredUnescaped: @{{{ foo }}}</p>
<p>rendered: {{ foo }}</p>
Expected:
+ <p>ignored: {{ foo }}</p>
+ <p>ignoredUnescaped: {{{ foo }}}</p>
+ <p>rendered: bar</p>Actual:
+ <p>ignored: {{ foo }}</p>
- <p>ignoredUnescaped: @{bar}</p>
+ <p>rendered: bar</p>Metadata
Metadata
Assignees
Labels
No labels