File: future.py

package info (click to toggle)
python-django 1.8.18-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 41,628 kB
  • sloc: python: 189,488; xml: 695; makefile: 194; sh: 169; sql: 11
file content (87 lines) | stat: -rw-r--r-- 2,652 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import warnings

from django.template import Library, defaulttags
from django.utils.deprecation import (
    RemovedInDjango19Warning, RemovedInDjango110Warning,
)

register = Library()


@register.tag
def ssi(parser, token):
    warnings.warn(
        "Loading the `ssi` tag from the `future` library is deprecated and "
        "will be removed in Django 1.9. Use the default `ssi` tag instead.",
        RemovedInDjango19Warning)
    return defaulttags.ssi(parser, token)


@register.tag
def url(parser, token):
    warnings.warn(
        "Loading the `url` tag from the `future` library is deprecated and "
        "will be removed in Django 1.9. Use the default `url` tag instead.",
        RemovedInDjango19Warning)
    return defaulttags.url(parser, token)


@register.tag
def cycle(parser, token):
    """
    This is the future version of `cycle` with auto-escaping.
    The deprecation is now complete and this version is no different
    from the non-future version so this is deprecated.

    By default all strings are escaped.

    If you want to disable auto-escaping of variables you can use::

        {% autoescape off %}
            {% cycle var1 var2 var3 as somecycle %}
        {% autoescape %}

    Or if only some variables should be escaped, you can use::

        {% cycle var1 var2|safe var3|safe  as somecycle %}
    """
    warnings.warn(
        "Loading the `cycle` tag from the `future` library is deprecated and "
        "will be removed in Django 1.10. Use the default `cycle` tag instead.",
        RemovedInDjango110Warning)
    return defaulttags.cycle(parser, token)


@register.tag
def firstof(parser, token):
    """
    This is the future version of `firstof` with auto-escaping.
    The deprecation is now complete and this version is no different
    from the non-future version so this is deprecated.

    This is equivalent to::

        {% if var1 %}
            {{ var1 }}
        {% elif var2 %}
            {{ var2 }}
        {% elif var3 %}
            {{ var3 }}
        {% endif %}

    If you want to disable auto-escaping of variables you can use::

        {% autoescape off %}
            {% firstof var1 var2 var3 "<strong>fallback value</strong>" %}
        {% autoescape %}

    Or if only some variables should be escaped, you can use::

        {% firstof var1 var2|safe var3 "<strong>fallback value</strong>"|safe %}

    """
    warnings.warn(
        "Loading the `firstof` tag from the `future` library is deprecated and "
        "will be removed in Django 1.10. Use the default `firstof` tag instead.",
        RemovedInDjango110Warning)
    return defaulttags.firstof(parser, token)