Use Macros
==========
These macros will help you to generate Fomantic-markup codes quickly and easily.
render_ui_nav_item()
--------------------
Render a Fomantic nav item.
Example
~~~~~~~~
.. code-block:: jinja
{% from 'fomantic/nav.html' import render_ui_nav_item %}
API
~~~~
.. py:function:: render_ui_nav_item(endpoint, text, iname, color=None, **kwargs)
:param endpoint: The endpoint used to generate ``URL``.
:param text: The text that will displayed on the item.
:param iname: The icon name.
:param color: Default: ``None``.
:param kwargs: Additional keyword arguments pass to ``url_for()``.
render_ui_breadcrumb_item()
----------------------------
Render a Fomantic UI breadcrumb item.
Example
~~~~~~~~
.. code-block:: jinja
{% from 'fomantic/nav.html' import render_ui_breadcrumb_item %}
API
~~~~
.. py:function:: render_ui_breadcrumb_item(endpoint, text, icon='right chevron', **kwargs)
:param endpoint: The endpoint used to generate ``URL``.
:param text: The text that will displayed on the item.
:param icon: Te icon name. Default: ``right chevron``.
:param kwargs: Additional keyword arguments pass to ``url_for()``.
render_ui_field()
-----------------
Render a form input for form field created by
`Flask-WTF/WTForms `_.
Example
~~~~~~~~
.. code-block:: jinja
{% from 'fomantic/form_ui.html' import render_ui_field %}
You can pass extra keyword arguements like ``class`` or ``placeholder`` for each HTML element.
Notice that a ``placeholder`` is only allowed by `W3C validation `_
when the input type is ``email``, ``number``, ``password``, ``search``, ``tel``,
``text`` or ``url``. However, it is possible to use a placeholder for input types
such as ``datetime``.
.. code-block:: jinja
{% from 'fomantic/form_ui.html' import render_ui_field %}
Notice the ``class`` value here will overwrite the ``render_kw={'class': '...'}`` you defined in
the form class. Flask-FomanticUI will combine the class value you passed with the ``class`` key of
the ``render_kw`` dict or the ``class`` keyword argments with Fomantic classes.
API
~~~~
.. py:function:: render_ui_field(field,\
form_type="basic",\
inverted=None,\
horizontal_columns=('sixteen', 'sixteen', 'sixteen'),\
button_style="",\
button_size="",\
button_map={})
:param field: The form field (attribute) to render.
:param form_type: Can be ``inline``. See the
Fomantic docs for details on different form layouts.
:param inverted: If ``True``, define a `inverted `_
form class. Default to ``None``.
:param horizontal_columns: *TODO in new relases:* (When using the horizontal layout, layout forms
like this. Must be a 3-tuple of ``(column-wide-mobile,
column-wide-tablet, column-wide-computer)``).
:param button_style: Set button style for ``SubmitField``.
Accept `Fomantic UI button style `_
name (i.e. primary, secondary, positive, negative, etc.). Default to ``primary`` (e.g.
``ui primary``). This will overwrite config ``FOMANTIC_BUTTON_STYLE``.
:param button_size: Set button size for ``SubmitField``. Accept Fomantic UI button.
size name: ``mini``, ``tiny``, ``small``, ``medium``, ``large``, ``big``, ``huge``, ``massive``.
Default to ``""`` and this will overwrite config ``FOMANTIC_BUTTON_SIZE``.
:param button_map: It given by ``button_map.get(field.name, button_style)``. See :ref:`button_customization` to
learn how to customize form buttons.
.. tip::
See :ref:`button_customization` to learn how to customize form buttons.
render_ui_form()
----------------
Render a complete form element for form object created by Flask-WTF/WTForms.
Example
~~~~~~~~
.. code-block:: jinja
{% from 'fomantic/form_ui.html' import render_ui_form %}
{{ render_ui_form(form) }}
API
~~~~
.. py:function:: render_ui_form(form,\
action="",\
method="post",\
inverted=None,\
extra_classes=None,\
color_title=None,\
role="form",\
form_type="basic",\
horizontal_columns=('sixteen', 'sixteen', 'sixteen'),\
enctype=None,\
button_map={},\
button_style="",\
button_size="",\
id="",\
novalidate=False,\
render_kw={},\
form_title=None)
:param form: The form to output.
:param action: The URL to receive form data.
:param method: ``