This may have been obvious to others, but it wasn't to me.
When I followed these instructions on using Pylons .9 r1034, I got an
error that 'templates' cannot be found. I started a app called
helloworld, created a hello controller and a hello.kid, and I'm assumed
I should translate "proj.templates" to my project name:
"helloworld.templates".
relevant line in the updated chunk of code from middleware.py:
config.add_template_engine('kid', 'helloworld.templates', kidopts)
error: exceptions.ImportError: No module named templates
I struggled with this for a while and it turns out that I needed an
empty file called __init__.py in my templates directory. This is basic
Python but I got stuck on it.
Ben Bangert wrote:
> New Templating
> ------------------------
>
> All render calls go through our custom Buffet, and you can swap out the
> default template engine for the one of your choice rather easily.
> Here's all that's necessary to use Kid templates instead of Myghty
> templates. Docs for the templating module that has the render calls:
> http://pylonshq.com/docs/0.9/module-pylons.templating.html
>
> In proj/config/middleware.py, right after the 'config.init_app....':
> # Pull the other engine and put a new one up first
> config.template_engines.pop()
> kidopts = {'kid.assume_encoding':'utf-8', 'kid.encoding':'utf-8'}
> config.add_template_engine('kid', 'proj.templates', kidopts)
>
> Now you could render a Kid template 'home.kid' with:
> def index(self):
> return render_response('home')
>
> If you want to use different configuration of the same template engine,
> you can also alias a template engine. Perhaps you want another set of
> Kid templates, you could just add under the above config lines:
> config.add_template_engine('kid', 'proj.templates', kidopts,
> alias='kid2')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---