Hi guys.

Lets discuss about this ticket <https://code.djangoproject.com/ticket/27703>

I think we need create new tag in template language to annotate context 
variable types. Something like PEP 484 
<https://www.python.org/dev/peps/pep-0484/> but on templates.
As in pep 484 main goal is provide easier static analysis, potential error 
checking and improve IDEs and editors support.
We can do this with new small tag. Something like:

@register.simpletag(name='var')
def type_hint(variable,variable_type_string: str) -> None:
    pass

Then we can annotate variable in template:

{% var request 'django.http.HttpResponse' %} %}

or

{% var is_paginated 'bool' %}

or

{% var user_or_none 'typing.Union[None, django.contrib.auth.models.User]' %}

maybe

{% var user_or_none 'typing.Union[None, 
django.conf.settings.AUTH_USER_MODEL]' %}
 

Main idea is add this template to django default tags, not third part 
application. 
Then IDE, editor plugins, and analysis tools can build support, based on 
this.

Similar links:
https://blog.jetbrains.com/idea/2009/08/enabling-implicit-context-variables-resolution-in-template-files/
https://weblogs.asp.net/scottgu/asp-net-mvc-3-new-model-directive-support-in-razor

English is not my mother tongue; please excuse any errors on my part.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/53df8783-7234-405e-a325-a8bed448cd35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to