| | 74 | {{if template_engine == 'mako'}} |
|---|
| | 75 | # Create the Mako TemplateLookup, with the default auto-escaping |
|---|
| | 76 | config['pylons.app_globals'].mako_lookup = TemplateLookup( |
|---|
| | 77 | directories=paths['templates'], |
|---|
| | 78 | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), |
|---|
| | 79 | input_encoding='utf-8', output_encoding='utf-8', |
|---|
| | 80 | imports=['from webhelpers.html import escape'], |
|---|
| | 81 | default_filters=['escape']) |
|---|
| | 82 | {{elif template_engine == 'genshi'}} |
|---|
| | 83 | |
|---|
| | 84 | # Create the Genshi TemplateLoader |
|---|
| | 85 | config['pylons.app_globals'].genshi_loader = TemplateLoader( |
|---|
| | 86 | paths['templates'], auto_reload=True) |
|---|
| | 87 | {{elif template_engine == 'jinja'}} |
|---|
| | 88 | |
|---|
| | 89 | # Create the Jinja Environment |
|---|
| | 90 | config['pylons.app_globals'].jinja_env = Environment(loader=ChoiceLoader( |
|---|
| | 91 | [FileSystemLoader(path) for path in paths['templates']])) |
|---|
| | 92 | # Jinja's unable to request c's attributes without strict_c |
|---|
| | 93 | config['pylons.strict_c'] = True |
|---|
| | 94 | {{endif}} |
|---|
| | 95 | |
|---|
| | 96 | # If you'd like to change the default template engine used to render |
|---|
| | 97 | # text/html content, edit these options. |
|---|
| | 98 | default_template_engine = 'genshi' |
|---|
| | 99 | default_template_engine_options = {} |
|---|
| | 100 | config['buffet.template_engines'].pop() |
|---|
| | 101 | config.add_template_engine(default_template_engine, '${package}.templates', |
|---|
| | 102 | default_template_engine_options) |
|---|
| | 103 | |
|---|
| 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 | | |
|---|