Skip to content

Prevent random filter from being inlined#478

Closed
snoack wants to merge 1 commit into
pallets:masterfrom
snoack:dont-inline-random
Closed

Prevent random filter from being inlined#478
snoack wants to merge 1 commit into
pallets:masterfrom
snoack:dont-inline-random

Conversation

@snoack

@snoack snoack commented Aug 10, 2015

Copy link
Copy Markdown
Contributor

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

k4nar commented Apr 20, 2017

Copy link
Copy Markdown

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

davidism commented Jul 5, 2017

Copy link
Copy Markdown
Member

New test doesn't fail when run on master.

@davidism

davidism commented Jul 5, 2017

Copy link
Copy Markdown
Member

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.

3 participants