I configured Pylons to be used with Mako. It works greate, but I can't
make webhelpers work.
In an inhereted template I had simple login form- it was rendered as I
expected. Then I tried to switch to using webhelpers to generate the
same form. But it doesn't work for me.
I added to helpers.py
from webhelpers.rails import *
But then I tried the following in my template:
+
<% h.text_field('email') %>
<% h.url_for('index2') %>
<% h.url_for(controller='index', action='login') %>
+
I get only "++", no errors.
What should I do to get this code working. And can anyone tell is
there any advantages of using webhelper for generating html instead of
simple html code.
I am using
pylons-0.9.6dev_r1956-py2.5.egg
mako-0.1.5-py2.5.egg
webhelpers-0.3-py2.5.egg
Thanks for your help.
Try ${ h.foobar() } instead of <% h.foobar() %>
Although <% ... %> should allow Python statements it doesn't output them
directly. A <% print h.text_field(...) %> may have worked but ${} is
preferred.
Christoph
Thank you.
--
Best regards,
Antipin Aleksei
I'm using Genshi instead of Mako, but if I were using Mako, I would
use Web helpers because a) they're convenient b) they're a great way
to ensure that data gets properly escaped.
Best Regards,
-jj
--
"'Software Engineering' is something of an oxymoron. It's very
difficult to have real engineering before you have physics, and there
isn't anything even close to a physics for software." -- L. Peter
Deutsch
config.init_app(global_conf, app_conf, package='your_project_name')
makopts = {}
config.add_template_engine('mako', 'your_project_name.templates',
makopts)
It works for me.
Regards.
Łukasz Biedrycki
With simple
config.init_app(global_conf, app_conf, package='pyoner',
template_engine='mako')
in middleware.py I have never got those errors and everything works just
fine, except for the topic;-).
Those are Myghty errors. The default engine is still Myghty. You'd
have to put "config.template_engines = []" before the add line, or use
the template_engine arg below.
> With simple
> config.init_app(global_conf, app_conf, package='pyoner',
> template_engine='mako')
> in middleware.py I have never got those errors and everything works just
> fine, except for the topic;-).
--
Mike Orr <slugg...@gmail.com>
It's strange- errors are gone, but <%%> syntax dosen't work :)