IIRC, response._caller acts like a function decorator. So it takes a
function and returns a function. I used to use Genshi like this:
def renderGenshi(func):
def _render():
output = func()
if not isinstance(dict, output):
return output
else:
# real Genshi render code goes here
return Genshi.render(response._view, output)
return _render
response._caller = renderGenshi
Naturally it was more complicated than that, but you get the idea.
That said, make sure Jinja2 is really what you want. I thought I liked
it until I learned that its context is immutable. (This means you can't
set response.title in a template and expect that change to propagate to
an included or extended template file. This was a deal-breaker for me.)
In case you're curious, I switched off of Genshi back to web2py
templates because Genshi only works on normal cPython platforms. It
blows up on Jython or AIX Python.
-tim
On 1/26/2010 9:05 PM, Thadeus Burgess wrote:
Its going to be your best bet in using a different templating
language. YOu will have to make sure to only parse your HTML requests
and not json/download etc.
Basically, response._caller is a function, that returns a string which
is the html.
So you would instead of response.render(d) you would do
jinja2.render(d) where d is the dict returned from the action, you
will of course have to tell jinja where to find templates and which
template to render based on action
jinja.render(d, '/applications/init/views/' + request.action+'.html')
-Thadeus
On Tue, Jan 26, 2010 at 8:24 PM, Alexandre <airm...@gmail.com
<mailto:airm...@gmail.com>> wrote:
Hi,
I want to replace web2py's template engine with Jinja 2
<http://jinja.pocoo.org/2/>, anyone has some experience doing
something similar? I'm trying to assign response._caller with a
custom function, but I'm not having much success, is that the
right way?
Thanks,
Alexandre Rosenfeld
Eng Comp 06 - USP São Carlos
FoG - http://fog.icmc.usp.br
IM Team - AIESEC
--
You received this message because you are subscribed to the Google
Groups "web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
<mailto:web2py@googlegroups.com>.
To unsubscribe from this group, send email to
web2py+unsubscr...@googlegroups.com
<mailto:web2py%2bunsubscr...@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.
--
You received this message because you are subscribed to the Google
Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.