Skip to content

Commit

Permalink
Trimming back default helper to demonstrate usage
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
bbangert committed Jul 8, 2008
1 parent 5973f42 commit 49bc0a6
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions pylons/templates/default_project/+package+/lib/helpers.py_tmpl
Expand Up @@ -3,29 +3,5 @@
Consists of functions to typically be used within templates, but also
available to Controllers. This module is available to both as 'h'.
"""
{{if template_engine == 'genshi'}}
from genshi.core import Markup
{{endif}}
from webhelpers import *
{{if template_engine == 'genshi'}}

def wrap_helpers(localdict):
"""Wrap the helpers for use in Genshi templates"""
def helper_wrapper(func):
def wrapped_helper(*args, **kwargs):
return Markup(func(*args, **kwargs))
try:
wrapped_helper.__name__ = func.__name__
except TypeError:
# Python < 2.4
pass
wrapped_helper.__doc__ = func.__doc__
return wrapped_helper
for name, func in localdict.iteritems():
if (not callable(func) or
not func.__module__.startswith('webhelpers.rails')):
continue
localdict[name] = helper_wrapper(func)

wrap_helpers(locals())
{{endif}}
# Import helpers as desired, or define your own, ie:
# from webhelpers.html.tags import checkbox, password

0 comments on commit 49bc0a6

Please sign in to comment.