How do I integrate Chameleon with Flask?

488 views Asked by At

I know jinja2 is the default built-in template engine for Flask. My question is:

Is it possible to integreate Chameleon with Flask ?

If so, how can I do that ?

This is how I did. I wrap the response string in a method..

from chameleon import PageTemplate

def execute_page(template_str, page):
    # Irrelevant
    template = PageTemplate(template_str)
    return template.render(page=page)

then consume the method and return the HTTPResponse. Hence, I completely skip render_template(template_file_name) approach.

My question is: Is it the proper (Pythonic, Flask) way to do?

0

There are 0 answers