copier_template_extensions
¤
Copier Template-Extensions package.
Special Jinja2 extension for Copier that allows to load extensions using file paths relative to the template root instead of Python dotted paths.
Classes:
-
ContextHook–Extension allowing to modify the Copier context.
-
TemplateExtensionLoader–Extension allowing to load other extensions using relative file paths.
ContextHook
¤
ContextHook(
extension_self: Extension, environment: Environment
)
Bases: Extension
Extension allowing to modify the Copier context.
Parameters:
-
(environment¤Environment) –The Jinja environment.
Methods:
-
hook–Abstract hook. Does nothing.
Attributes:
-
update(bool) –Deprecated attribute to indicate whether the context should be updated with the value returned by
hook.
Source code in src/copier_template_extensions/_internal/context.py
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 | |
update
class-attribute
instance-attribute
¤
update: bool = _sentinel
Deprecated attribute to indicate whether the context should be updated with the value returned by hook.
hook
¤
Abstract hook. Does nothing.
Override this method to either return a new context dictionary that will be used to update the original one, or modify the context object in-place.
Parameters:
Raises:
-
NotImplementedError–This method must be overridden in a subclass, and instead return either the same context instance modified, or new context instance (dictionary).
Source code in src/copier_template_extensions/_internal/context.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
TemplateExtensionLoader
¤
TemplateExtensionLoader(environment: Environment)
Bases: Extension
Extension allowing to load other extensions using relative file paths.
Parameters:
-
(environment¤Environment) –The Jinja environment.
Source code in src/copier_template_extensions/_internal/loader.py
40 41 42 43 44 45 46 47 48 | |