neurino
neurino

Reputation: 12395

Using Webhelpers in mako template in Pyramid

How do I use Webhelpers in a Mako template in my Pyramid app?


In Pylons I had global helper variable h to use in my templates so I could simply do:

${h.stylesheet_link("/css/default.css")}

given I import stylesheet_link from webhelpers.html.tags in Pylons lib/helpers.py

I don't want to go with Akhet and replicate full Pylons behavior but simply I'd like to get some base (recommended?) usage of a package that's (cite) officially endorsed, but not Pyramid add-on.

Upvotes: 3

Views: 1572

Answers (1)

Rick
Rick

Reputation: 16224

The cookbook in the docs refers to this here

http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/templates/templates.html

You basically inject the helpers using a before-render event so that it's available in your templates. Hope that helps.

Upvotes: 6

Related Questions