| 71 | | {{if template_engine == 'mako'}} |
|---|
| 72 | | # Create the Mako TemplateLookup, with the default auto-escaping |
|---|
| 73 | | config['pylons.app_globals'].mako_lookup = TemplateLookup( |
|---|
| 74 | | directories=paths['templates'], |
|---|
| 75 | | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), |
|---|
| 76 | | input_encoding='utf-8', output_encoding='utf-8', |
|---|
| 77 | | imports=['from webhelpers.html import escape'], |
|---|
| 78 | | default_filters=['escape']) |
|---|
| 79 | | {{elif template_engine == 'genshi'}} |
|---|
| 80 | | |
|---|
| 81 | | # Create the Genshi TemplateLoader |
|---|
| 82 | | config['pylons.app_globals'].genshi_loader = TemplateLoader( |
|---|
| 83 | | paths['templates'], auto_reload=True) |
|---|
| 84 | | {{elif template_engine == 'jinja'}} |
|---|
| 85 | | |
|---|
| 86 | | # Create the Jinja Environment |
|---|
| 87 | | config['pylons.app_globals'].jinja_env = Environment(loader=ChoiceLoader( |
|---|
| 88 | | [FileSystemLoader(path) for path in paths['templates']])) |
|---|
| 89 | | # Jinja's unable to request c's attributes without strict_c |
|---|
| 90 | | config['pylons.strict_c'] = True |
|---|
| 91 | | {{endif}} |
|---|
| 92 | | |
|---|
| 93 | | # If you'd like to change the default template engine used to render |
|---|
| 94 | | # text/html content, edit these options. |
|---|
| 95 | | default_template_engine = 'genshi' |
|---|
| 96 | | default_template_engine_options = {} |
|---|
| 97 | | config['buffet.template_engines'].pop() |
|---|
| 98 | | config.add_template_engine(default_template_engine, '${package}.templates', |
|---|
| 99 | | default_template_engine_options) |
|---|
| 100 | | |
|---|
| | 85 | # Template rendering setup: |
|---|
| | 86 | |
|---|
| | 87 | {{if template_engine == 'mako'}} |
|---|
| | 88 | # Create the Mako TemplateLookup, with the default auto-escaping |
|---|
| | 89 | config['pylons.app_globals'].mako_lookup = TemplateLookup( |
|---|
| | 90 | directories=paths['templates'], |
|---|
| | 91 | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), |
|---|
| | 92 | input_encoding='utf-8', output_encoding='utf-8', |
|---|
| | 93 | imports=['from webhelpers.html import escape'], |
|---|
| | 94 | default_filters=['escape']) |
|---|
| | 95 | |
|---|
| | 96 | config['tg.default_renderer'] = 'mako' |
|---|
| | 97 | |
|---|
| | 98 | {{elif template_engine == 'genshi'}} |
|---|
| | 99 | # Create the Genshi TemplateLoader |
|---|
| | 100 | config['pylons.app_globals'].genshi_loader = TemplateLoader( |
|---|
| | 101 | paths['templates'], auto_reload=True) |
|---|
| | 102 | |
|---|
| | 103 | config['tg.default_renderer'] = 'genshi' |
|---|
| | 104 | |
|---|
| | 105 | {{elif template_engine == 'jinja'}} |
|---|
| | 106 | # Create the Jinja Environment |
|---|
| | 107 | config['pylons.app_globals'].jinja_env = Environment(loader=ChoiceLoader( |
|---|
| | 108 | [FileSystemLoader(path) for path in paths['templates']])) |
|---|
| | 109 | # Jinja's unable to request c's attributes without strict_c |
|---|
| | 110 | config['pylons.strict_c'] = True |
|---|
| | 111 | config['tg.default_renderer'] = 'jinja' |
|---|
| | 112 | {{endif}} |
|---|
| | 113 | |
|---|
| | 114 | # config['template_engines'] contains a dictionary of renderers which you can update here |
|---|
| | 115 | # the keys are the name of the rendering engine, and the values the rendering function. |
|---|
| | 116 | # by default render_json, and render_genshi, and render_mako are available. |
|---|
| | 117 | |
|---|
| | 118 | # app_globals['template_engines']['my_engine] = my_renderer |
|---|
| | 119 | |
|---|