Posts Tagged ‘mako’

Unicode in Mako using Pylons

Small post regarding unicode support in mako. I learned yesterday that mako not only has input and output encoding options but also an default_filter encoding. In the environment.py file, in your Pylons config folder, you need all these three to be sure that everything is enoded as unicode. Remember though that the default_filters argument can have big impact on performance.

(If someone knows the configuration files for other frameworks, please write a comment about it and I’ll add it to the post)

Please read the Mako unicode chapter here if you want the gory details.

#environment.py
 config['pylons.app_globals'].mako_lookup = TemplateLookup(
        input_encoding='utf-8', 
        output_encoding='utf-8', 
        default_filters=['decode.utf8'] )