X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/1dba84d30c4323acb722de2011ff7a0bff9148aa..82b08f79564159d7acbcaf255ed1ac1fb4882e64:/templatetags/nodes.py diff --git a/templatetags/nodes.py b/templatetags/nodes.py index 8a98630..5ae507d 100644 --- a/templatetags/nodes.py +++ b/templatetags/nodes.py @@ -25,7 +25,7 @@ class NodeURLNode(template.Node): if self.node: node = self.node.resolve(context) else: - node = context['node'] + node = context.get('node', None) if not node: return settings.TEMPLATE_STRING_IF_INVALID @@ -51,12 +51,11 @@ class NodeURLNode(template.Node): subpath = reverse(view_name, urlconf=node.view, args=args, kwargs=kwargs) except NoReverseMatch: if self.as_var is None: - raise + if settings.TEMPLATE_DEBUG: + raise + return settings.TEMPLATE_STRING_IF_INVALID else: - if subpath[0] == '/': - subpath = subpath[1:] - - url = node.get_absolute_url() + subpath + url = node.construct_url(subpath) if self.as_var: context[self.as_var] = url @@ -68,7 +67,7 @@ class NodeURLNode(template.Node): @register.tag(name='node_url') def do_node_url(parser, token): """ - {% node_url [for ] [as ] [as ] %} {% node_url with [for ] [as ] %} {% node_url [ [ ...] ] [for ] [as ] %} {% node_url [= [= ...] ] [for ] [as ]%}