Browse Source

Added module support to templated decorator.

pull/1638/head
Armin Ronacher 15 years ago
parent
commit
7e1db5978c
  1. 11
      docs/patterns/viewdecorators.rst

11
docs/patterns/viewdecorators.rst

@ -117,10 +117,10 @@ three examples do exactly the same::
return dict(value=42) return dict(value=42)
As you can see, if no template name is provided it will use the endpoint As you can see, if no template name is provided it will use the endpoint
of the URL map + ``'.html'``. Otherwise the provided template name is of the URL map with dots converted to slashes + ``'.html'``. Otherwise
used. When the decorated function returns, the dictionary returned is the provided template name is used. When the decorated function returns,
passed to the template rendering function. If `None` is returned, an the dictionary returned is passed to the template rendering function. If
empty dictionary is assumed. `None` is returned, an empty dictionary is assumed.
Here the code for that decorator:: Here the code for that decorator::
@ -133,7 +133,8 @@ Here the code for that decorator::
def decorated_function(*args, **kwargs): def decorated_function(*args, **kwargs):
template_name = template template_name = template
if template_name is None: if template_name is None:
template_name = request.endpoint + '.html' template_name = request.endpoint \
.replace('.', '/') + '.html'
ctx = f(*args, **kwargs) ctx = f(*args, **kwargs)
if ctx is None: if ctx is None:
ctx = {} ctx = {}

Loading…
Cancel
Save