Skip to content

Conversation

@dwoz
Copy link
Contributor

@dwoz dwoz commented Dec 14, 2025

When using import_yaml to load YAML data with multi-line scalars (using |), the newlines were being rendered as literal \n instead of actual newlines when passed through Jinja templates.

This fix adds an _unescape_newlines function that recursively converts literal \n sequences back to actual newlines in the context dictionary before it's used for templating.

  • Added _unescape_newlines function to salt/utils/templates.py
  • Applied unescape to context before creating decoded_context
  • Updated test to remove to_dict filter reference

Fixes #30690

When using import_yaml to load YAML data with multi-line scalars (using |),
the newlines were being rendered as literal \n instead of actual newlines
when passed through Jinja templates.

This fix adds an _unescape_newlines function that recursively converts
literal \n sequences back to actual newlines in the context dictionary
before it's used for templating.

- Added _unescape_newlines function to salt/utils/templates.py
- Applied unescape to context before creating decoded_context
- Updated test to remove to_dict filter reference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant