How to integrate Chameleon with Flask?

I know jinja2 is Flask's built-in default templating engine. My question is:

Can a chameleon be combined with a flask?

If so, how can I do this?

So I did. I am terminating the response line in a method.

from chameleon import PageTemplate

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

      

then use the method and return HTTPResponse. Hence I am skipping the approach entirely render_template(template_file_name)

.

My question is: is this correct (Pythonic, Flask)?

+3


source to share





All Articles