-
-
Notifications
You must be signed in to change notification settings - Fork 131
Add support for new escape sequences and Python compatible rendering #804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rals Implements \xNN (hexadecimal) and \NNN (octal) escape sequences to match Jinja2 compatibility. The \0 sequence is now handled as part of the octal system for consistency. Fixes #803 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Make clippy happy
Adds an optional pycompat_rendering flag to Environment that enables rendering values in a format compatible with Python Jinja2: - `true`/`false` render as `True`/`False` - `none` renders as `None` - Strings use Python-style escaping and quoting This addresses compatibility issues for SQL templating and other use cases where precise output format matters. The feature is disabled by default to maintain backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
fn test_pycompat_rendering_complex_case() { | ||
let mut env = Environment::new(); | ||
|
||
// Test the specific case from the issue: {{ [true, false, none, 'foo', "bar'baz", '\x13'] }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment disagrees with the test implementation below.
@@ -0,0 +1,72 @@ | |||
use minijinja::{context, Environment}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really don't need this example here.
minijinja/src/utils.rs
Outdated
} | ||
|
||
fn parse_hex_byte(&self, chars: &mut Chars) -> Result<u8, Error> { | ||
let hexnum = chars.chain(repeat('\0')).take(2).collect::<String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably error if the sequence is just \x1
I'm going to merge part one of it in a separate PR: #805 |
Implements \xNN (hexadecimal) and \NNN (octal) escape sequences to match Jinja2 compatibility. The \0 sequence is now handled as part of the octal system for consistency.
This was made with Claude Code for this video: https://www.youtube.com/watch?v=sQYXZCUvpIc
Fixes #803
Fixes #785
🤖 Generated with Claude Code