root/sandbox/PylonsGenshi/trunk/pylonsgenshi/helpers.py

Revision 53, 1.6 kB (checked in by s0undt3ch, 11 months ago)

Added a README.txt and only wrap the MinificationWebHelpers if they're correctly imported.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id URL LastChangedDate Rev LastChangedBy
Line 
1# -*- coding: utf-8 -*-
2# vim: sw=4 ts=4 fenc=utf-8
3# =============================================================================
4# $Id$
5# =============================================================================
6#             $URL$
7# $LastChangedDate$
8#             $Rev$
9#   $LastChangedBy$
10# =============================================================================
11# Copyright (C) 2007 UfSoft.org - Pedro Algarvio <ufs@ufsoft.org>
12#
13# Please view LICENSE for additional licensing information.
14# =============================================================================
15
16from webhelpers import *
17try:
18    from minwebhelpers import *
19    _HAVE_MINWEBHELPERS = True
20except ImportError:
21    _HAVE_MINWEBHELPERS = False
22from genshi.builder import tag
23from genshi.core import Markup as _Markup
24
25def _wrap_helpers(localdict):
26    def helper_wrapper(func):
27        def wrapped_helper(*args, **kw):
28            return _Markup(func(*args, **kw))
29        wrapped_helper.__name__ = func.__name__
30        return wrapped_helper
31    for name, func in localdict.iteritems():
32         if not callable(func) or not \
33             func.__module__.startswith('webhelpers.rails'):
34             continue
35         localdict[name] = helper_wrapper(func)
36    if _HAVE_MINWEBHELPERS:
37        localdict['javascript_include_tag'] = \
38                                        helper_wrapper(javascript_include_tag)
39        localdict['stylesheet_link_tag'] = helper_wrapper(stylesheet_link_tag)
40
41_wrap_helpers(locals())
42
43__all__ = [__name for __name in locals().keys() if not __name.startswith('_') ]
Note: See TracBrowser for help on using the browser.