I think a third party implementation could be done first for the separate tag. I also think you'd learn more and iterate faster by building some tooling on top of the tags whilst a third party app before merging with core was considered. One idea that springs to mind is allowing multiple type declarations in the same tag rather than requiring *"{% var " *written multiple times.
On 9 January 2017 at 15:38, Дмитрий Симонов <dem...@gmail.com> wrote: > 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 > <https://groups.google.com/d/msgid/django-developers/53df8783-7234-405e-a325-a8bed448cd35%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Adam -- 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/CAMyDDM2jxHm-PhD4VUQt%3DUbWeHV%3D51zKW%3Das9Kzc-Bqg4sCoZg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.