Skip to content
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

Use Jinja2 NativeEnvironment #71

Closed
ryanrichholt opened this issue May 8, 2019 · 1 comment
Closed

Use Jinja2 NativeEnvironment #71

ryanrichholt opened this issue May 8, 2019 · 1 comment

Comments

@ryanrichholt
Copy link
Collaborator

http://jinja.pocoo.org/docs/2.10/nativetypes/

Because Jinja2 essentially revolves around html templates, variables are returned as strings. This code fails to find the correct index path because read_len is set to the string '100' instead of preserving the integer:

{% set read_len =  sample.read_length|default(100) %}
{% set star_index = constants.phoenix.star_indices[read_len] %}

Ansible users also ran into this problem, and created a new environment that preserves the types: pallets/jinja#708

Here are the docs:
http://jinja.pocoo.org/docs/2.10/nativetypes/

Need to try changing, then validate that it doesn't mess up anything else.

@ryanrichholt
Copy link
Collaborator Author

Not changing this for now because it forces you to also cast variables to strings when rendering in templates if they are not already strings. I've been working fine without it so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant