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

Prevent random filter from being inlined #478

Closed
wants to merge 1 commit into from
Closed

Prevent random filter from being inlined #478

wants to merge 1 commit into from

Conversation

snoack
Copy link
Contributor

@snoack snoack commented Aug 10, 2015

Currently, due to #476 environment filters like random aren't optimized/inlined. While this is a bug for any other filter, the random filter should never be inlined, but always be evaluated at runtime. Otherwise, once the template is compiled, the random filter would always give the same results. So this pull request turns random into a contextfilter to prevent it from being inlined.

@k4nar
Copy link

k4nar commented Apr 20, 2017

I've encountered this bug with Jinja 2.9.6 and this patch fixes it.

If this isn't merged, a workaround is to simply override env.filters['random'] with the do_random function from this patch.

@davidism
Copy link
Member

davidism commented Jul 5, 2017

New test doesn't fail when run on master.

@davidism
Copy link
Member

davidism commented Jul 5, 2017

Continued in #734.

@davidism davidism closed this Jul 5, 2017
@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.

None yet

3 participants