How to call a python function with no parameters in a jinja2 template
===


I have managed to call python functions from jinja2 by using custom filters, but I can only seem to call functions with one or more parameters. In the following I have had to pass a junk parameter in order to treat chris_rocks as a function rather than a variable. It doesn't work if I just call chris_rocks().

Is there a different way to force this to be a function call or should I be using a different approach?

code:

    def ctest(stuff):
        return "yeah!"

    template_env = jinja2.Environment (loader = jinja2.FileSystemLoader(template_file_root))
    #custom filters
    template_env.filters['ctest'] = ctest

template:

    Working? {{ junk|ctest }}

output:

    working? yeah!