MCPcopy Index your code
hub / github.com/nodejs/node / select_template

Method select_template

tools/inspector_protocol/jinja2/environment.py:833–857  ·  view source on GitHub ↗

Works like :meth:`get_template` but tries a number of templates before it fails. If it cannot find any of the templates, it will raise a :exc:`TemplatesNotFound` exception. .. versionadded:: 2.3 .. versionchanged:: 2.4 If `names` contains a :class:`Templ

(self, names, parent=None, globals=None)

Source from the content-addressed store, hash-verified

831
832 @internalcode
833 def select_template(self, names, parent=None, globals=None):
834 """Works like :meth:`get_template` but tries a number of templates
835 before it fails. If it cannot find any of the templates, it will
836 raise a :exc:`TemplatesNotFound` exception.
837
838 .. versionadded:: 2.3
839
840 .. versionchanged:: 2.4
841 If `names` contains a :class:`Template` object it is returned
842 from the function unchanged.
843 """
844 if not names:
845 raise TemplatesNotFound(message=u'Tried to select from an empty list '
846 u'of templates.')
847 globals = self.make_globals(globals)
848 for name in names:
849 if isinstance(name, Template):
850 return name
851 if parent is not None:
852 name = self.join_path(name, parent)
853 try:
854 return self._load_template(name, globals)
855 except TemplateNotFound:
856 pass
857 raise TemplatesNotFound(names)
858
859 @internalcode
860 def get_or_select_template(self, template_name_or_list,

Callers 1

Calls 4

make_globalsMethod · 0.95
join_pathMethod · 0.95
_load_templateMethod · 0.95
TemplatesNotFoundClass · 0.90

Tested by

no test coverage detected