X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/46997a51ed0ceb16ddbac712fbcb552a86cdc9e2..61b73fe068172f02d6c47e2b5387161919ec9618:/philo/templatetags/nodes.py diff --git a/philo/templatetags/nodes.py b/philo/templatetags/nodes.py index 1d095bc..52da236 100644 --- a/philo/templatetags/nodes.py +++ b/philo/templatetags/nodes.py @@ -1,20 +1,6 @@ """ The node template tags are automatically included as builtins if :mod:`philo` is an installed app. -.. templatetag:: node_url - -node_url --------- - -The :ttag:`node_url` tag allows access to :meth:`.View.reverse` from a template for a :class:`.Node`. By default, the :class:`.Node` that is used for the call is pulled from the context variable ``node``; however, this can be overridden with the ``[for ]`` option. - -Usage:: - - {% node_url [for ] [as ] %} - {% node_url with [for ] [as ] %} - {% node_url [ [ ...] ] [for ] [as ] %} - {% node_url [= [= ...] ] [for ] [as ] %} - """ from django import template @@ -53,7 +39,7 @@ class NodeURLNode(template.Node): if self.with_obj is None and self.view_name is None: url = node.get_absolute_url() else: - if not node.view.accepts_subpath: + if not node.accepts_subpath: return settings.TEMPLATE_STRING_IF_INVALID if self.with_obj is not None: @@ -84,13 +70,17 @@ class NodeURLNode(template.Node): return url -@register.tag(name='node_url') -def do_node_url(parser, token): +@register.tag +def node_url(parser, token): """ - {% node_url [for ] [as ] %} - {% node_url with [for ] [as ] %} - {% node_url [ [ ...] ] [for ] [as ] %} - {% node_url [= [= ...] ] [for ] [as ] %} + The :ttag:`node_url` tag allows access to :meth:`.View.reverse` from a template for a :class:`.Node`. By default, the :class:`.Node` that is used for the call is pulled from the context variable ``node``; however, this can be overridden with the ``[for ]`` option. + + Usage:: + + {% node_url [for ] [as ] %} + {% node_url with [for ] [as ] %} + {% node_url [ [ ...] ] [for ] [as ] %} + {% node_url [= [= ...] ] [for ] [as ] %} """ params = token.split_contents()