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

Output finalize function issue #63

Closed
tzzt opened this issue Oct 2, 2011 · 3 comments · Fixed by #1080
Closed

Output finalize function issue #63

tzzt opened this issue Oct 2, 2011 · 3 comments · Fixed by #1080
Milestone

Comments

@tzzt
Copy link

@tzzt tzzt commented Oct 2, 2011

The finalize function seems to be executed on the whole template, not only on variables.

E.g. a function like
def fin(s): print s; return s
dumps the whole template file.

@jturmel

This comment has been minimized.

Copy link

@jturmel jturmel commented Jul 3, 2013

Any input on this, we're running into the same thing?

We like to look at the variable expressions and modify them based on different criteria but returning the entire template makes this impossible.

@ntrepid8

This comment has been minimized.

Copy link

@ntrepid8 ntrepid8 commented Mar 29, 2014

I'm seeing this too. It seems like finalize should run only on expressions evaluated during render, but it runs when the template is constructed also.

@godsarmy

This comment has been minimized.

Copy link

@godsarmy godsarmy commented Jan 20, 2016

is this fixed? i still see it in the latest version (2.8).

rom jinja2 import Environment, Template

context = {'k': 'v'}

template = """
abc
{{ k }}
def
"""

def fin(data):
    return 'replaced'

env = Environment(finalize=fin)

tpl = env.from_string(template, template_class=Template)

print tpl.render(**context)

It displayed 'replacedreplacedreplaced', we want this to be fixed as we need this feature very explicitly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.