I'm not a mako user myself, so I'm not sure how mako filters are handled inside mako itself.
What I can tell you is that the 'h' variable is injected by TG itself every time the controller renders a template registered using @expose. So if you render the template manually the h variable won't be available. Also if you render a template inside a template the h variable must be explicitly passed to the second template. I don't know if this is the case. On Thu, Apr 5, 2012 at 6:18 PM, Moritz Schlarb <[email protected]> wrote: > Hi there! > > I'm not sure if this is more related to tg, pylons or mako, so I > thought, I'd just ask here. > > The source code: > > <%def name="event_list(events)"> > > <dl> > % for event in events: > ## <dt>${h.link(event.name, tg.url('/events/%s' % event.url))} > (${event.type | string.capitalize})</dt> > <dt>${event.link} (${event.type | string.capitalize})</dt> > <dd>${event.description | n, h.striphtml, h.cut }</dd> > % endfor > </dl> > > </%def> > > throws > > NameError: global name 'h' is not defined > > with that line commented out. > When I remove the commenting, it works (except for that I get the link > generated twice). > > Pylons Traceback: > http://pylonshq.com/tracebacks/a133f8a44af50ae18c806ab32160f8b0 > > It seems as if lib.helpers as h isn't imported when I only access the > property as a filter. > Or could it be related to that I'm just defining a function? I use > namespace to import the needed function from a generic lists.mak into > the rendered templates. > > Please help! ;) > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" 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/turbogears?hl=en. > -- You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en.

