Example #1
0
    def get_context_data(self, **kwargs):
        load_all_installed_template_libraries()

        filters = []
        app_libs = list(libraries.items())
        builtin_libs = [(None, lib) for lib in builtins]
        for module_name, library in builtin_libs + app_libs:
            for filter_name, filter_func in library.filters.items():
                title, body, metadata = utils.parse_docstring(filter_func.__doc__)
                if title:
                    title = utils.parse_rst(title, 'filter', _('filter:') + filter_name)
                if body:
                    body = utils.parse_rst(body, 'filter', _('filter:') + filter_name)
                for key in metadata:
                    metadata[key] = utils.parse_rst(metadata[key], 'filter', _('filter:') + filter_name)
                if library in builtins:
                    tag_library = ''
                else:
                    tag_library = module_name.split('.')[-1]
                filters.append({
                    'name': filter_name,
                    'title': title,
                    'body': body,
                    'meta': metadata,
                    'library': tag_library,
                })
        kwargs.update({'filters': filters})
        return super(TemplateFilterIndexView, self).get_context_data(**kwargs)
Example #2
0
    def get_context_data(self, **kwargs):
        load_all_installed_template_libraries()

        tags = []
        app_libs = list(libraries.items())
        builtin_libs = [(None, lib) for lib in builtins]
        for module_name, library in builtin_libs + app_libs:
            for tag_name, tag_func in library.tags.items():
                title, body, metadata = utils.parse_docstring(tag_func.__doc__)
                if title:
                    title = utils.parse_rst(title, 'tag', _('tag:') + tag_name)
                if body:
                    body = utils.parse_rst(body, 'tag', _('tag:') + tag_name)
                for key in metadata:
                    metadata[key] = utils.parse_rst(metadata[key], 'tag',
                                                    _('tag:') + tag_name)
                if library in builtins:
                    tag_library = ''
                else:
                    tag_library = module_name.split('.')[-1]
                tags.append({
                    'name': tag_name,
                    'title': title,
                    'body': body,
                    'meta': metadata,
                    'library': tag_library,
                })
        kwargs.update({'tags': tags})
        return super(TemplateTagIndexView, self).get_context_data(**kwargs)
Example #3
0
 def get_templatetag_module(self):
     """
     Return the templatetags module name for which the current class is used.
     It's used to render the nocache blocks by loading the correct module
     """
     if not self.__class__._templatetags_module:
         try:
             # find the library including the main templatetag of the current class
             module = [name for name, lib in libraries.items() if self._templatetags['cache'] in lib.tags.values()][0]
         except:
             module = 'adv_cache'
         self.__class__._templatetags_module = module
     return self.__class__._templatetags_module
Example #4
0
 def get_templatetag_module(self):
     """
     Return the templatetags module name for which the current class is used.
     It's used to render the nocache blocks by loading the correct module
     """
     if not self.__class__._templatetags_module:
         try:
             # find the library including the main templatetag of the current class
             module = [
                 name for name, lib in libraries.items()
                 if self._templatetags['cache'] in lib.tags.values()
             ][0]
         except:
             module = 'adv_cache'
         self.__class__._templatetags_module = module
     return self.__class__._templatetags_module