code: def to_template(template_name=None):
      
  
      def decorator(view_func):
          def _wrapped_view(request, *args, **kwargs):
              result = view_func(request, *args, **kwargs)
              if isinstance(result, dict):
                  return TemplateResponse(request, result.pop('TEMPLATE', template_name), result)
              return result 
          return wraps(view_func, assigned=available_attrs(view_func))(_wrapped_view)
      return decorator
docs: Decorator for simple call TemplateResponse
      Examples:
      @to_template("test.html")
      def test(request):
          return {'test': 100}
  
      @to_template
      def test2(request):
          return {'test': 100, 'TEMPLATE': 'test.html'}
  
      @to_template
      def test2(request, template_name='test.html'):
          return {'test': 100, 'TEMPLATE': template_name}