Output finalize function issue #63

Open
tzzt opened this Issue Oct 2, 2011 · 3 comments

Projects

None yet

4 participants

@tzzt

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

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

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

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