Load a template by name with :attr:`loader` and return a :class:`Template`. If the template does not exist a :exc:`TemplateNotFound` exception is raised. :param name: Name of the template to load. When loading templates from the filesystem, "/" is used as the pat
(
self,
name: t.Union[str, "Template"],
parent: t.Optional[str] = None,
globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
)
| 980 | |
| 981 | @internalcode |
| 982 | def get_template( |
| 983 | self, |
| 984 | name: t.Union[str, class="st">"Template"], |
| 985 | parent: t.Optional[str] = None, |
| 986 | globals: t.Optional[t.MutableMapping[str, t.Any]] = None, |
| 987 | ) -> class="st">"Template": |
| 988 | class="st">"""Load a template by name with :attr:`loader` and return a |
| 989 | :class:`Template`. If the template does not exist a |
| 990 | :exc:`TemplateNotFound` exception is raised. |
| 991 | |
| 992 | :param name: Name of the template to load. When loading |
| 993 | templates from the filesystem, class="st">"/" is used as the path |
| 994 | separator, even on Windows. |
| 995 | :param parent: The name of the parent template importing this |
| 996 | template. :meth:`join_path` can be used to implement name |
| 997 | transformations with this. |
| 998 | :param globals: Extend the environment :attr:`globals` with |
| 999 | these extra variables available for all renders of this |
| 1000 | template. If the template has already been loaded and |
| 1001 | cached, its globals are updated with any new items. |
| 1002 | |
| 1003 | .. versionchanged:: 3.0 |
| 1004 | If a template is loaded from cache, ``globals`` will update |
| 1005 | the template&class="cm">#x27;s globals instead of ignoring the new values. |
| 1006 | |
| 1007 | .. versionchanged:: 2.4 |
| 1008 | If ``name`` is a :class:`Template` object it is returned |
| 1009 | unchanged. |
| 1010 | class="st">""" |
| 1011 | if isinstance(name, Template): |
| 1012 | return name |
| 1013 | if parent is not None: |
| 1014 | name = self.join_path(name, parent) |
| 1015 | |
| 1016 | return self._load_template(name, globals) |
| 1017 | |
| 1018 | @internalcode |
| 1019 | def select_template( |