Returns a list of templates for this environment. This requires that the loader supports the loader's :meth:`~BaseLoader.list_templates` method. If there are other files in the template folder besides the actual templates, the returned list can be filtered. There a
(self, extensions=None, filter_func=None)
| 731 | log_function('Finished compiling templates') |
| 732 | |
| 733 | def list_templates(self, extensions=None, filter_func=None): |
| 734 | """Returns a list of templates for this environment. This requires |
| 735 | that the loader supports the loader's |
| 736 | :meth:`~BaseLoader.list_templates` method. |
| 737 | |
| 738 | If there are other files in the template folder besides the |
| 739 | actual templates, the returned list can be filtered. There are two |
| 740 | ways: either `extensions` is set to a list of file extensions for |
| 741 | templates, or a `filter_func` can be provided which is a callable that |
| 742 | is passed a template name and should return `True` if it should end up |
| 743 | in the result list. |
| 744 | |
| 745 | If the loader does not support that, a :exc:`TypeError` is raised. |
| 746 | |
| 747 | .. versionadded:: 2.4 |
| 748 | """ |
| 749 | x = self.loader.list_templates() |
| 750 | if extensions is not None: |
| 751 | if filter_func is not None: |
| 752 | raise TypeError('either extensions or filter_func ' |
| 753 | 'can be passed, but not both') |
| 754 | filter_func = lambda x: '.' in x and \ |
| 755 | x.rsplit('.', 1)[1] in extensions |
| 756 | if filter_func is not None: |
| 757 | x = list(ifilter(filter_func, x)) |
| 758 | return x |
| 759 | |
| 760 | def handle_exception(self, exc_info=None, rendered=False, source_hint=None): |
| 761 | """Exception handling helper. This is used internally to either raise |
no test coverage detected