Template tags¶
Load the library in templates with {% load djmvc %}.
Filters¶
- djmvc.templatetags.djmvc.html_attributes(attrs)[source]¶
Render attrs as a safe HTML attribute string.
Boolean
Truerenders as a boolean attribute (name only).Falserenders asname="false". Other values are escaped and quoted. Keys that do not match a safe attribute name pattern are skipped.Example:
{{ view.form_attributes|html_attributes }} {{ action|unpoly_attributes:'model_menu'|html_attributes }}
- djmvc.templatetags.djmvc.unpoly_attributes(view, context='')[source]¶
Return Unpoly link attributes for view in context.
Delegates to
unpoly_attributes()when the view defines it; otherwise returns an empty dict. context is passed through (for example'model_menu','object_menu','list_action_bar').Pair with
html_attributes()in templates:{{ action|unpoly_attributes:'model_menu'|html_attributes }}
{% eval %} tag¶
- djmvc.templatetags.djmvc.do_eval(parser, token)[source]¶
{% eval %}template tag — call a callable and assign the result.Syntax:
{% eval callable positional_arg keyword=value as variable_name %}
callable is a template variable path (for example
view.pagination_url). Positional and keyword arguments are resolved in the template context and passed to the callable. The return value is stored in variable_name for the remainder of the template.Example:
{% load djmvc %} {% eval view.pagination_url 2 as url %} <a href="{{ url }}">Page 2</a> {% eval view.some_method "arg" user=view.request.user as result %}