Coverage for jinjazzle/ext/uuid.py: 100%
8 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-24 22:03 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-24 22:03 +0000
1"""
2Description
3-----------
5UUIDExtension provides the capability to generate UUID version 4 (UUID4) strings directly within your templates.
8.. autoclass:: UUIDExtension
11.. py:function:: uuid
13 Return a UUID string.
15 Available as a function.
17 .. code-block:: jinja
19 Generated UUID: {{ uuid() }}
20"""
22import uuid as m_uuid
24from jinja2.ext import Extension
27def _uuid():
28 """
29 Generate UUID4.
30 """
31 return str(m_uuid.uuid4())
34# pylint: disable=abstract-method
35class UUIDExtension(Extension):
36 """
37 Jinja2 extension to generate uuid4 string.
38 """
40 def __init__(self, environment):
41 """
42 Jinja2 Extension constructor.
43 """
44 super().__init__(environment)
46 environment.globals.update(uuid=_uuid)