MCPcopy
hub / github.com/pallets/jinja / get_or_select_template

Method get_or_select_template

src/jinja2/environment.py:1073–1090  ·  view source on GitHub ↗

Use :meth:`select_template` if an iterable of template names is given, or :meth:`get_template` if one name is given. .. versionadded:: 2.3

(
        self,
        template_name_or_list: t.Union[
            str, "Template", t.List[t.Union[str, "Template"]]
        ],
        parent: t.Optional[str] = None,
        globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
    )

Source from the content-addressed store, hash-verified

1071
1072 @internalcode
1073 def get_or_select_template(
1074 self,
1075 template_name_or_list: t.Union[
1076 str, "Template", t.List[t.Union[str, "Template"]]
1077 ],
1078 parent: t.Optional[str] = None,
1079 globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
1080 ) -> "Template":
1081 """Use :meth:`select_template` if an iterable of template names
1082 is given, or :meth:`get_template` if one name is given.
1083
1084 .. versionadded:: 2.3
1085 """
1086 if isinstance(template_name_or_list, (str, Undefined)):
1087 return self.get_template(template_name_or_list, parent, globals)
1088 elif isinstance(template_name_or_list, Template):
1089 return template_name_or_list
1090 return self.select_template(template_name_or_list, parent, globals)
1091
1092 def from_string(
1093 self,

Callers 2

Calls 2

get_templateMethod · 0.95
select_templateMethod · 0.95

Tested by 2