Template vs TemplateProxy

Hey @carltongibson
Hope you are doing great !
I was summarizing the coming of template-partials into django when a question just struck me. Why can’t we directly use Template class (the one from base.py) in place of TemplateProxy. 'Cause TemplateProxy seemed of use when we use partials as a third-party library.
But if we are getting this inside django, why not use Template directly ?
So, I did some go-through and it’s actually of use.
First of all, the instrumented test rendering issue will get solved and there won’t be a need to separately get the template_rendered flag triggered.
Second, this would allow each partial to have it’s own source and get_exception_info (could be separate or same as that of parent template depending on the implementation complexity )
Also, this would ease the partial to be used separately using some_file#partial.
And Template already has a _render method, so it will be used with django-components without trouble.

I could be going in the wrong direction. Please correct me if so.

Hi @YogyaChugh — yes, interesting idea. It’s certainly something we can look at.

Historically, TemplateProxy exists to bootstrap the partial implementation. I needed a lightweight wrapper that looked like a template. (It needed to take a context in order to render the node list.) It may well be that using Template directly would have served, but without actually sitting down to it I can’t say immediately.

I would imagine there are a couple of similar adjustments that we’d make moving into django.templates. :+1:

Yup ! Looking forward to it.