code: def templated(template=None, *templates):
      
  
      def decorator(func):
          @functools.wraps(func)
          def wrapper(*args, **kwargs):
              template_ = template
              if template_ is None:
                  template_ = request.endpoint.split('.', 1)[1].replace(
                      '.', '/') + '.html'
              context = func(*args, **kwargs)
              if context is None:
                  context = {}
              elif not isinstance(context, dict):
                  return context
              return custom_render_template(
                  list(chain(to_list(template_), templates)), **context)
  
          return wrapper
  
      return decorator
docs: Decorate a view function with one or more default template name.
      This will try templates in the custom folder first,
      the theme's original ones second.
  
      :param template: template name or template name list