• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:no +full:- +full:undefined

14 ------
31 .. code-block:: python
53 .. code-block:: python
59 .. code-block:: python
75 --------------
77 The high-level API is the API you will use in the application to load and
78 render Jinja templates. The :ref:`low-level-api` on the other side is only
80 <jinja-extensions>`.
103 A dict of filters for this environment. As long as no template was
105 see :ref:`writing-filters`. For valid filter names have a look at
106 :ref:`identifier-naming`.
110 A dict of test functions for this environment. As long as no
112 see :ref:`writing-tests`. For valid test names have a look at
113 :ref:`identifier-naming`.
118 in a template. As long as no template was loaded it's safe
119 to modify this dict. For more details see :ref:`global-namespace`.
120 For valid object names have a look at :ref:`identifier-naming`.
143 .. method:: undefined([hint, obj, name, exc])
145 Creates a new :class:`Undefined` object for `name`. This is useful
146 for filters or functions that may return undefined objects for
151 provided as `exc` is raised if something with the generated undefined
152 object is done that the undefined object does not allow. The default
156 The most common way to create an undefined object is by providing
159 return environment.undefined(name='some_name')
163 undefined object the holder object to improve the error message::
166 return environment.undefined(obj=obj, name='attr')
169 the :func:`first` filter creates an undefined object that way::
171 return environment.undefined('no first item, sequence was empty')
174 was accessed) it should be passed to the undefined object, even if
175 a custom `hint` is provided. This gives undefined objects the
213 ------------
218 autoescape extension is removed and built-in. However autoescaping is
222 on a per-template basis (HTML versus text for instance).
249 the `autoescape` block (see :ref:`autoescape-overrides`).
252 .. _identifier-naming:
255 --------------------
265 ``[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*```.
268 Undefined Types
269 ---------------
271 These classes can be used as undefined types. The :class:`Environment`
272 constructor takes an `undefined` parameter that can be one of those classes
273 or a custom subclass of :class:`Undefined`. Whenever the template engine is
275 created and returned. Some operations on undefined values are then allowed,
279 disallows all operations beside testing if it's an undefined object.
281 .. autoclass:: jinja2.Undefined()
286 undefined object.
290 Either `None` or the owner object that caused the undefined object
295 The name for the undefined variable / attribute or just `None`
296 if no such information exists.
300 The exception that the undefined object wants to raise. This
307 from the undefined hints stored on the undefined object.
315 There is also a factory function that can decorate undefined objects to
320 Undefined objects are created by calling :attr:`undefined`.
324 :class:`Undefined` is implemented by overriding the special
326 :class:`Undefined` class implements ``__str__`` to returns an empty
331 .. code-block:: python
333 class NullUndefined(Undefined):
341 :attr:`~Undefined._undefined_exception`. Because this is very
343 :meth:`~Undefined._fail_with_undefined_error` that raises the error
345 regular :class:`Undefined` but fails on iteration::
347 class NonIterableUndefined(Undefined):
353 -----------
397 The current :ref:`eval-context`.
417 -------
446 .. _bytecode-cache:
449 --------------
489 -------------
504 - Template rendering requires an event loop to be available to the
507 - The compiled code uses ``await`` for functions and attributes, and
512 - Sync methods and filters become wrappers around their corresponding
527 --------
551 if no other target is defined by the call explicitly.
565 .. _ext-i18n-trimmed:
569 :ref:`i18n-extension` will always unify linebreaks and surrounding
574 ---------
594 to HTML-safe sequences. Use this if you need to display text that might
615 ----------
642 file system (most likely utf-8, or mbcs on Windows systems).
649 .. _writing-filters:
652 --------------
662 def datetimeformat(value, format='%H:%M / %d-%m-%Y'):
675 publication date: {{ article.pub_date|datetimeformat('%d-%m-%Y') }}
678 is useful if a filter wants to return an undefined value or check the current
706 .. _eval-context:
709 ------------------
768 .. _writing-tests:
771 ------------
773 Tests work like filters just that there is no way for a test to get access
808 .. _global-namespace:
811 --------------------
821 .. _low-level-api:
824 -------------
828 <jinja-extensions>` techniques. Unless you know exactly what you are doing we
864 The low-level API is fragile. Future Jinja versions will try not to
870 ------------