loaders
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
ChoiceLoader jinjarope.loaders A loader which combines multiple other loaders. |
||
DictLoader jinjarope.loaders A loader to load static content from a path->template-str mapping. |
||
FileSystemLoader jinjarope.loaders A loader to load templates from the file system. |
||
FunctionLoader jinjarope.loaders A loader for loading templates from a function. |
||
LoaderMixin jinjarope.loaders Loader mixin which allows to OR loaders into a choice loader. |
||
ModuleLoader jinjarope.loaders This loader loads templates from precompiled templates. |
||
PackageLoader jinjarope.loaders A loader for loading templates from a package. |
||
PrefixLoader jinjarope.loaders A loader for prefixing other loaders. |
🛈 DocStrings¶
ChoiceLoader
¶
Bases: LoaderMixin
, ChoiceLoader
A loader which combines multiple other loaders.
Source code in src/jinjarope/loaders.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
DictLoader
¶
Bases: LoaderMixin
, DictLoader
A loader to load static content from a path->template-str mapping.
Source code in src/jinjarope/loaders.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
FileSystemLoader
¶
Bases: LoaderMixin
, FileSystemLoader
A loader to load templates from the file system.
Source code in src/jinjarope/loaders.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
FunctionLoader
¶
Bases: LoaderMixin
, FunctionLoader
A loader for loading templates from a function.
The function takes a template path as parameter and either returns a (text, None, uptodate_fn) tuple or just the text as str.
Source code in src/jinjarope/loaders.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
LoaderMixin
¶
Loader mixin which allows to OR loaders into a choice loader.
Source code in src/jinjarope/loaders.py
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 |
|
__contains__
¶
__contains__(path: str)
Check whether given path is loadable by this loader.
Source code in src/jinjarope/loaders.py
35 36 37 |
|
__getitem__
¶
Return the template object for given template path.
Source code in src/jinjarope/loaders.py
31 32 33 |
|
get_template_source
¶
get_template_source(template_path: str)
Return the source for given template path.
Source code in src/jinjarope/loaders.py
50 51 52 |
|
prefixed_with
¶
prefixed_with(prefix: str)
Return loader wrapped in a PrefixLoader instance with given prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix
|
str
|
The prefix to use |
required |
Source code in src/jinjarope/loaders.py
42 43 44 45 46 47 48 |
|
ModuleLoader
¶
Bases: LoaderMixin
, ModuleLoader
This loader loads templates from precompiled templates.
Templates can be precompiled with :meth:Environment.compile_templates
.
Source code in src/jinjarope/loaders.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
PackageLoader
¶
Bases: LoaderMixin
, PackageLoader
A loader for loading templates from a package.
Source code in src/jinjarope/loaders.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
__init__
¶
__init__(
package: str | ModuleType, package_path: str | None = None, encoding: str = "utf-8"
) -> None
Instanciate a PackageLoader.
Compared to the jinja2 equivalent, this loader also supports
ModuleType
s and dotted module paths for the package
argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package
|
str | ModuleType
|
The python package to create a loader for |
required |
package_path
|
str | None
|
If given, use the given path as the root. |
None
|
encoding
|
str
|
The encoding to use for loading templates |
'utf-8'
|
Source code in src/jinjarope/loaders.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
PrefixLoader
¶
Bases: LoaderMixin
, PrefixLoader
A loader for prefixing other loaders.
Source code in src/jinjarope/loaders.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
from_json
¶
from_json(dct_or_list: dict | list | None | BaseLoader) -> BaseLoader | None
Create a loader based on a json representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dct_or_list
|
dict | list | None | BaseLoader
|
A dictionary or list describing loaders. |
required |
Source code in src/jinjarope/loaders.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|