Closed rrauenza closed 10 months ago
When using NativeEnvironment, jinja seems to convert strings that look like integers to integers.
>>> import jinja2.nativetypes >>> env = jinja2.nativetypes.NativeEnvironment() >>> result = env.from_string('{{ x }}').render(x=2) >>> type(result) <class 'int'> >>> result = env.from_string('{{ x }}').render(x='2') >>> type(result) <class 'int'> >>> type(env.from_string('{{ x|string}}').render(x='2')) <class 'int'>
I would expect in the second case that jinja would preserve that x is a string. Is this behavior intentional?
Environment:
(also does it with float like strings... and bools...)
Yes, this is intended.
Is this already exposed in the docs? I didn't see it in the NativeEnvironment docs and could propose a change there if that would be helpful.
NativeEnvironment
When using NativeEnvironment, jinja seems to convert strings that look like integers to integers.
I would expect in the second case that jinja would preserve that x is a string. Is this behavior intentional?
Environment:
(also does it with float like strings... and bools...)