OpenQuizz
Une application de gestion des contenus pédagogiques
|
Data Structures | |
class | Cycler |
class | Joiner |
class | LRUCache |
class | Namespace |
Functions | |
def | contextfunction (f) |
def | evalcontextfunction (f) |
def | environmentfunction (f) |
def | internalcode (f) |
def | is_undefined (obj) |
def | consume (iterable) |
def | clear_caches () |
def | import_string (import_name, silent=False) |
def | open_if_exists (filename, mode="rb") |
def | object_type_repr (obj) |
def | pformat (obj, verbose=False) |
def | urlize (text, trim_url_limit=None, rel=None, target=None) |
def | generate_lorem_ipsum (n=5, html=True, min=20, max=100) |
def | unicode_urlencode (obj, charset="utf-8", for_qs=False) |
def | select_autoescape (enabled_extensions=("html", "htm", "xml"), disabled_extensions=(), default_for_string=True, default=False) |
def | htmlsafe_json_dumps (obj, dumper=None, **kwargs) |
def | soft_unicode (s) |
Variables | |
missing | |
internal_code | |
concat | |
have_async_gen | |
def jinja2.utils.clear_caches | ( | ) |
Jinja keeps internal caches for environments and lexers. These are used so that Jinja doesn't have to recreate environments and lexers all the time. Normally you don't have to care about that but if you are measuring memory consumption you may want to clean the caches.
def jinja2.utils.consume | ( | iterable | ) |
Consumes an iterable without doing anything with it.
def jinja2.utils.contextfunction | ( | f | ) |
This decorator can be used to mark a function or method context callable. A context callable is passed the active :class:`Context` as first argument when called from the template. This is useful if a function wants to get access to the context or functions provided on the context object. For example a function that returns a sorted list of template variables the current template exports could look like this:: @contextfunction def get_exported_names(context): return sorted(context.exported_vars)
def jinja2.utils.environmentfunction | ( | f | ) |
This decorator can be used to mark a function or method as environment callable. This decorator works exactly like the :func:`contextfunction` decorator just that the first argument is the active :class:`Environment` and not context.
def jinja2.utils.evalcontextfunction | ( | f | ) |
This decorator can be used to mark a function or method as an eval context callable. This is similar to the :func:`contextfunction` but instead of passing the context, an evaluation context object is passed. For more information about the eval context, see :ref:`eval-context`. .. versionadded:: 2.4
def jinja2.utils.generate_lorem_ipsum | ( | n = 5 , |
|
html = True , |
|||
min = 20 , |
|||
max = 100 |
|||
) |
Generate some lorem ipsum for the template.
def jinja2.utils.htmlsafe_json_dumps | ( | obj, | |
dumper = None , |
|||
** | kwargs | ||
) |
Works exactly like :func:`dumps` but is safe for use in ``<script>`` tags. It accepts the same arguments and returns a JSON string. Note that this is available in templates through the ``|tojson`` filter which will also mark the result as safe. Due to how this function escapes certain characters this is safe even if used outside of ``<script>`` tags. The following characters are escaped in strings: - ``<`` - ``>`` - ``&`` - ``'`` This makes it safe to embed such strings in any place in HTML with the notable exception of double quoted attributes. In that case single quote your attributes or HTML escape it in addition.
def jinja2.utils.import_string | ( | import_name, | |
silent = False |
|||
) |
Imports an object based on a string. This is useful if you want to use import paths as endpoints or something similar. An import path can be specified either in dotted notation (``xml.sax.saxutils.escape``) or with a colon as object delimiter (``xml.sax.saxutils:escape``). If the `silent` is True the return value will be `None` if the import fails. :return: imported object
def jinja2.utils.internalcode | ( | f | ) |
Marks the function as internally used
def jinja2.utils.is_undefined | ( | obj | ) |
Check if the object passed is undefined. This does nothing more than performing an instance check against :class:`Undefined` but looks nicer. This can be used for custom filters or tests that want to react to undefined variables. For example a custom default filter can look like this:: def default(var, default=''): if is_undefined(var): return default return var
def jinja2.utils.object_type_repr | ( | obj | ) |
Returns the name of the object's type. For some recognized singletons the name of the object is returned instead. (For example for `None` and `Ellipsis`).
def jinja2.utils.open_if_exists | ( | filename, | |
mode = "rb" |
|||
) |
Returns a file descriptor for the filename if that file exists, otherwise ``None``.
def jinja2.utils.pformat | ( | obj, | |
verbose = False |
|||
) |
Prettyprint an object. Either use the `pretty` library or the builtin `pprint`.
def jinja2.utils.select_autoescape | ( | enabled_extensions = ("html", "htm", "xml") , |
|
disabled_extensions = () , |
|||
default_for_string = True , |
|||
default = False |
|||
) |
Intelligently sets the initial value of autoescaping based on the filename of the template. This is the recommended way to configure autoescaping if you do not want to write a custom function yourself. If you want to enable it for all templates created from strings or for all templates with `.html` and `.xml` extensions:: from jinja2 import Environment, select_autoescape env = Environment(autoescape=select_autoescape( enabled_extensions=('html', 'xml'), default_for_string=True, )) Example configuration to turn it on at all times except if the template ends with `.txt`:: from jinja2 import Environment, select_autoescape env = Environment(autoescape=select_autoescape( disabled_extensions=('txt',), default_for_string=True, default=True, )) The `enabled_extensions` is an iterable of all the extensions that autoescaping should be enabled for. Likewise `disabled_extensions` is a list of all templates it should be disabled for. If a template is loaded from a string then the default from `default_for_string` is used. If nothing matches then the initial value of autoescaping is set to the value of `default`. For security reasons this function operates case insensitive. .. versionadded:: 2.9
def jinja2.utils.soft_unicode | ( | s | ) |
def jinja2.utils.unicode_urlencode | ( | obj, | |
charset = "utf-8" , |
|||
for_qs = False |
|||
) |
Quote a string for use in a URL using the given charset. This function is misnamed, it is a wrapper around :func:`urllib.parse.quote`. :param obj: String or bytes to quote. Other types are converted to string then encoded to bytes using the given charset. :param charset: Encode text to bytes using this charset. :param for_qs: Quote "/" and use "+" for spaces.
def jinja2.utils.urlize | ( | text, | |
trim_url_limit = None , |
|||
rel = None , |
|||
target = None |
|||
) |
Converts any URLs in text into clickable links. Works on http://, https:// and www. links. Links can have trailing punctuation (periods, commas, close-parens) and leading punctuation (opening parens) and it'll still do the right thing. If trim_url_limit is not None, the URLs in link text will be limited to trim_url_limit characters. If nofollow is True, the URLs in link text will get a rel="nofollow" attribute. If target is not None, a target attribute will be added to the link.
concat |
have_async_gen |
internal_code |
missing |