Trouble with WebHelpers

4 views
Skip to first unread message

Seth

unread,
Jun 14, 2009, 10:42:52 PM6/14/09
to TurboGears
Hey guys,

I'm having some trouble with WebHelpers (TG 2.0 with Mako templates).
The documentation seems to be a bit misleading/confusing about
accessing helpers from within the templates (in some places it says to
use h.html.tags, in others I've seen helpers.html.tags), but on top of
that I can't seem to find a bunch of the methods such as
html.link_to_if, html.link_to_unless, html.tags.stylesheet_link, etc.

In my Mako templates I've managed to get ${h.html.HTML.a('Home
href=tg.url('/'))} working, but it seems like there should be a
simpler way.


Could someone please shine some light on my confusion?


Also, a "TG v2.x Cheatsheet" (like http://wiki.pylonshq.com/display/pylonsmisc/Pylons+Cheatsheet)
would be incredibly helpful to TG newbies!

Thanks,
Seth

Jorge Vargas

unread,
Jun 14, 2009, 11:19:16 PM6/14/09
to turbo...@googlegroups.com
On Sun, Jun 14, 2009 at 10:42 PM, Seth<seediff...@gmail.com> wrote:
>
> Hey guys,
>
> I'm having some trouble with WebHelpers (TG 2.0 with Mako templates).
> The documentation seems to be a bit misleading/confusing about
> accessing helpers from within the templates (in some places it says to
> that I can't seem to find a bunch of the methods such as
> use h.html.tags, in others I've seen helpers.html.tags), but on top of

this is because one letter variables are deprecated in pylons and will
be removed in future versions. Currently both 'h' and 'helpers' both
point to your projects /lib/helpers , but use helpers for forward
compatibility.

> html.link_to_if, html.link_to_unless, html.tags.stylesheet_link, etc.
>
not everything is imported again see your lib/helpers to pull in the content.

> In my Mako templates I've managed to get ${h.html.HTML.a('Home
> href=tg.url('/'))} working, but it seems like there should be a
> simpler way.
>
That is correct the default path is that long.
h = tg template variable
html = webhelpers main html generator module
HTML = instance of the "content builder"
a = method of HTML

This the the content of one of my helpers package

from webhelpers import date, feedgenerator, html, number, misc, text
from webhelpers.rails.number import number_to_phone

the first line is the default which I haven't bothered to remove. The
second one allows me to do ${h.number_to_phone(str)}
>
> Could someone please shine some light on my confusion?
>
>
> Also, a "TG v2.x Cheatsheet" (like http://wiki.pylonshq.com/display/pylonsmisc/Pylons+Cheatsheet)
> would be incredibly helpful to TG newbies!
>
yes indeed.

> Thanks,
> Seth
> >
>

Seth

unread,
Jun 15, 2009, 8:16:48 PM6/15/09
to TurboGears
Jorge,

Thank you.

Perhaps somewhere in the docs it should be noted that you have to use
'helpers.html.HTML.tag()' since the current listing of
'webhelpers.html.tags.TAGNAME()' is misleading.

Seth

Jorge Vargas

unread,
Jun 21, 2009, 8:48:00 PM6/21/09
to turbo...@googlegroups.com
please make a comment on the doc page where you saw that for it to be fixed.
Reply all
Reply to author
Forward
0 new messages