fobi.templatetags package¶
Submodules¶
fobi.templatetags.fobi_tags module¶
Gets the plugin. Note, that
entry
shall be a instance offobi.models.FormElementEntry
orfobi.models.FormHandlerEntry
.Syntax: {% get_fobi_plugin entry as [context_var_name] %}
Example: {% get_fobi_plugin entry as plugin %}
{% get_fobi_plugin entry as plugin %} {{ plugin.render }}
Gets the form handler plugin custom actions. Note, that
plugin
shall be a instance offobi.models.FormHandlerEntry
.Syntax: {% get_fobi_form_handler_plugin_custom_actions [plugin] [form_entry] as [context_var_name] %} Example: {% get_fobi_form_handler_plugin_custom_actions plugin form_entry as form_handler_plugin_custom_actions %}
Get form field type.
Syntax:
{% get_form_field_type [field] as [context_var_name] %}
Example:
{% get_form_field_type form.field as form_field_type %} {% if form_field_type.is_checkbox %} ... {% endif %}
Get form hidden fields errors.
Syntax: {% get_form_hidden_fields_errors [form] as [context_var_name] %} Example: {% get_form_hidden_fields_errors form as form_hidden_fields_errors %} {{ form_hidden_fields_errors.as_ul }}
Checks the permissions
Syntax: {% has_edit_form_entry_permissions as [var_name] %}
Example: {% has_edit_form_entry_permissions %}
or
{% has_edit_form_entry_permissions as has_permissions %}
Render auth link.
fobi.templatetags.future_compat module¶
Outputs the first variable passed that is not False, without escaping.
Outputs nothing if all the passed variables are False.
Sample usage:
{% firstof var1 var2 var3 %}
This is equivalent to:
{% if var1 %} {{ var1|safe }} {% elif var2 %} {{ var2|safe }} {% elif var3 %} {{ var3|safe }} {% endif %}
but obviously much cleaner!
You can also use a literal string as a fallback value in case all passed variables are False:
{% firstof var1 var2 var3 "fallback value" %}
If you want to escape the output, use a filter tag:
{% filter force_escape %} {% firstof var1 var2 var3 "fallback value" %} {% endfilter %}