This adds a feature flag for PREVENT_ACCIDENTAL_EXPRESSIONS where, when combining output, it will check if the last character of the previous node and the first character of the current node create a tag/expression/note start string. If so, it will add a \n{#- #} spacer, which, if the entire output is passed back to jinjava, will tokensise properly, and maintain the correct whitespace due to the left-trim of the note.
This adds a feature flag for
PREVENT_ACCIDENTAL_EXPRESSIONS
where, when combining output, it will check if the last character of the previous node and the first character of the current node create a tag/expression/note start string. If so, it will add a\n{#- #}
spacer, which, if the entire output is passed back to jinjava, will tokensise properly, and maintain the correct whitespace due to the left-trim of the note.Note/expression trimming is added in https://github.com/HubSpot/jinjava/pull/1122
For example:
Would normally output as:
But with this feature enabled, it will output as:
Which will prevent a
PrintTag
from being in it, if it were to be passed back into the interpreter.