Templates Tags and Filters¶
Nuit provides a handlful of template tags and filters designed to abstract some of the complexities of writing templates for the framework.
Tags¶
extend
¶
Extends another template, passing any keyword arguments to the parent template (prefixed by nuit_
). For example:
{% extend 'nuit/base.html' topbar=True %}
results in the variable nuit_topbar
being available (and set to True
) in nuit/base.html
.
foundation_form
¶
Renders a form using Foundation’s form styles in the given layout. Takes one required arguement, and one optional:
-
form
¶ The Django Form object. Works with all standard Django Form classes.
-
csrf_enabled
¶ Default: True
Whether to include the CSRF token or not.
-
collapse_container
¶ Default: False
Whether to collapse the side padding of the form elements.
Further options are specified between the foundation_form and end_foundation_form
tags. For more details, see the Forms documentation. Example usage:
{% foundation_form my_form_object %}
title, first_name, surname
email_address
{% end_foundation_form %}
Filters¶
message_class
¶
Given a message object from Django’s django.contrib.messages
, returns a string containing the CSS alert-box class for Foundation alert boxes corresponding to the message’s level (DEBUG
, INFO
, SUCCESS
, WARNING
or ERROR
). Used to style the message alert boxes:
{% for message in messages %}
<div data-alert class='alert-box {{message|message_class}}'>{{message}}</div>
{% endfor %}