Ejemplo n.º 1
0
def region(parser, token):
    """
    Defines a live-updateable region::

        {% region "identifier" fields="family_name,given_name" tag="div" %}
            {# Template code #}
        {% endregion %}

    The identifier should be a short string which is unique for the whole
    project, or at least for a given view. It is used to identify the region
    when live-updating, it should therefore be usable as a part of a HTML
    ``id`` attribute. The identifer should not start with an underscore,
    those names are reserved for internal bookkeeping.

    ``fields`` is a comma-separated list of fields (or other identifiers)
    which are used inside the given region. It is recommended to use the
    field and relation names here, but you are free to use anything you
    want. It can also be left empty if you purely want to update regions by
    their identifier.

    The ``tag`` argument defines the HTML tag used to render the region.
    The default tag is a ``div``.

    Additional keyword arguments will be rendered as attributes. This can
    be used to specify classes, data attributes or whatever you desire.
    """

    nodelist = parser.parse(('endregion', ))
    parser.delete_first_token()

    return RegionNode(
        nodelist, *parse_args_and_kwargs(parser,
                                         token.split_contents()[1:]))
Ejemplo n.º 2
0
def region(parser, token):
    """
    Defines a live-updateable region::

        {% region "identifier" fields="family_name,given_name" tag="div" %}
            {# Template code #}
        {% endregion %}

    The identifier should be a short string which is unique for the whole
    project, or at least for a given view. It is used to identify the region
    when live-updating, it should therefore be usable as a part of a HTML
    ``id`` attribute. The identifer should not start with an underscore,
    those names are reserved for internal bookkeeping.

    ``fields`` is a comma-separated list of fields (or other identifiers)
    which are used inside the given region. It is recommended to use the
    field and relation names here, but you are free to use anything you
    want. It can also be left empty if you purely want to update regions by
    their identifier.

    The ``tag`` argument defines the HTML tag used to render the region.
    The default tag is a ``div``.

    Additional keyword arguments will be rendered as attributes. This can
    be used to specify classes, data attributes or whatever you desire.
    """

    nodelist = parser.parse(("endregion",))
    parser.delete_first_token()

    return RegionNode(nodelist, *parse_args_and_kwargs(parser, token.split_contents()[1:]))
Ejemplo n.º 3
0
def editable(parser, token):
    """
    Defines an editable or live-updateable template region

    Editable regions::

        {% editable edit="title,description" %}
            <h2>{{ title }}</h2>
            <p>{{ description|linebreaksbr }}</p>
        {% endeditable %}

    Only live-updated regions, no editing support:

        {% editable used="title,description %}
            {{ title }} ...
        {% endeditable %}
    """
    nodelist = parser.parse(('endeditable',))
    parser.delete_first_token()

    return EditableNode(nodelist,
        *parse_args_and_kwargs(parser, token.split_contents()[1:]))
Ejemplo n.º 4
0
def testtag(parser, token):
    return TestNode(*parse_args_and_kwargs(parser, token.split_contents()[1:]))