Reputation: 59
I have a custom filter that looks like this
register = template.Library()
@register.filter
def makebreadcrumbs(value, arg):
pass
How can I pass multiple arguments to the filter?
{% with request.resolver_match.namespace as name_space %}
{{ request.path|makebreadcrumbs:name_space|safe }}
{% endwith %}
In the code above makebreadcrumbs
is my custom filter, request.path
is a variable (value), and name_space
is an argument.
Upvotes: 1
Views: 492
Reputation: 2663
I think what you want is a Django simple tag which can accept multiple arguments:
@register.simple_tag(takes_context=True)
def breadcrumbs(path, name_space):
# your code
return ...
{% breadcrumbs request.path request.resolver_match.namespace %}
Upvotes: 2