Skip to content

preserve quotes between nodes in native env#1086

Merged
davidism merged 1 commit intomasterfrom
native-string-literal
Oct 22, 2019
Merged

preserve quotes between nodes in native env#1086
davidism merged 1 commit intomasterfrom
native-string-literal

Conversation

@davidism
Copy link
Copy Markdown
Member

@davidism davidism commented Oct 22, 2019

closes #1020

Due to the way the lexer works, '{{ a }}', '{{ b }}' would get parsed as the nodes ', {{ a }}, ', ', {{ b }}, '. native_concat would get called on the intermediate node ', ', which parses to a string, which drops the quotes.

Now, if literal_eval results in a string, it is re-quoted except for the top-level concat in Template.render. The original quote character is preserved. This carries the quotes through to the final call to literal_eval, so quotes around expressions are preserved.

cc @jctanner @mkrizek

@davidism davidism added this to the 2.11.0 milestone Oct 22, 2019
@davidism davidism merged commit 6e50bbd into master Oct 22, 2019
@davidism davidism deleted the native-string-literal branch October 22, 2019 20:33
mkrizek added a commit to mkrizek/ansible that referenced this pull request Oct 23, 2019
Fixes ansible#58527

Updates our copy of native_concat to include changes introduced in
pallets/jinja#1086.
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jinja2 NativeEnvironment dropping single quotes between elements in template to render

1 participant