|
@@ -87,20 +87,32 @@ def html_link(text, view, *args, **kwarg
|
|
|
|
|
|
|
|
|
@register.simple_tag(takes_context=True)
|
|
|
def active_link(context, url_name, return_value='active', **kwargs):
|
|
|
def active_link(context, view_name, return_value='active', *args, **kwargs):
|
|
|
"""
|
|
|
This template tag can be used to check if the provided URL matches against
|
|
|
the path from the request or not.
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
context - Context of the current view being called.
|
|
|
context
|
|
|
Context of the view being rendered.
|
|
|
|
|
|
view_name
|
|
|
Name of the view against which the context request path is
|
|
|
being checked.
|
|
|
|
|
|
url_name - Name of the URL that's being checked against current path from
|
|
|
request.
|
|
|
args
|
|
|
Positional parametrs for the view.
|
|
|
|
|
|
kwargs
|
|
|
Keyword arguments for the view.
|
|
|
|
|
|
Returns:
|
|
|
Value from return_value parameter if the rendered context
|
|
|
corresponds to specified view, empty string otherwise.
|
|
|
"""
|
|
|
|
|
|
matches = current_url_equals(context, url_name, **kwargs)
|
|
|
matches = current_url_equals(context, view_name, *args, **kwargs)
|
|
|
|
|
|
return return_value if matches else ''
|
|
|
|
|
@@ -127,6 +139,10 @@ def current_url_equals(context, view_nam
|
|
|
|
|
|
kwargs
|
|
|
Keyword arguments for the view.
|
|
|
|
|
|
Returns:
|
|
|
True, if the current URL equals to resolved view URL, False
|
|
|
otherwise.
|
|
|
"""
|
|
|
|
|
|
request = context.get('request')
|