--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
{% easy_map <address> [<width> <height>] [<zoom>] [using <template_name>] %}+1
Template tags should be forced to have a simple syntax. Users should not
have to look up the syntax each time.
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to django-developers+unsubscribe@googlegroups.com.
I guess it's not the "point of this thread" but rather Evgeny's design
proposal. Alex' intention seems to be discussion on a new syntax to
define template tags.
> For many years, writing templatetags has been among the most hilariously
> complicated things we Django developers did. Anyone who has written parsing for
> templatetags, over and over, shares this pain. Further, the current syntax
> present a tremendous problem for Armin Ronacher's GSOC towards template
> compilation: template tags define a ``render()`` method, which takes the
> current context (a stack of dictionaries) and perform some behavior which is
> opaque to the caller. This is a problem because one of the core objectives of
> the template compilation infrastructure is to store the template context in
> Python local variables, rather than in dictionaries. For all these reasons,
> several of us (myself, Idan, Russ, Carl Meyer, Andrew Godwin, Jonas Obrist,
> Chris Beaven) just sat down (we actually stood, mostly) and tried to iron out a
> proposal that solves these problems, taking inspiration from the plethora of
> libraries that exist today.
>
> We ultimately created two possible solutions, one inspired primarily by
> django-classy-tags and django-templatetag-sugar, the other mostly inspired by
> django-ttags.
FTR, the app is called django-ttag, not django-ttags.
I'd like to express my sincere discomfort with the two example cases you used
to develop the API. At least from the experience I have with writing template
tags (with the standard API, @simple_tag, django-template-sugar,
django-classy-tags and django-tagcon/ttag) it was the simple use cases that
were more common, rather than the complex in day-to-day work. While one could
say that this has something to do with my coding style and clients, I'd have
to say that keeping the template tag API simple instead of complex has always
been a major goal. So unless there was a decision to start encouraging moving
business logic from the views to template tags (which would be indicated by
increased complexity) I don't see a reason to prefer the API that allows
complex API.
As a matter of remote contribution to the discussion at the sprint, I've just
checked if django-ttag (the example which you preferred for the simple case)
is capable of passing your complex case, too (yes):
https://github.com/jezdez/django-ttag/compare/django-tag-api
I'm happy that there was some discussion at the conference sprint though,
since it's an important topic, but I'd appreciate if you'd provide further
explanation of why you prefer the first, django-classy-tag and
django-template-sugar influenced example.
Since I've also worked on django-ttag (including when it was still called
django-tagcon a long time ago) quite a bit, I assume you mostly discussed how
to handle ordering the different kinds of arguments (positional vs. keyword
vs. "named" arguments). Luckily we already have a pretty strong convention for
that, as you can see when specifying forms or models. Which is why I'm
confused why an "args" class attribute would be needed in your preferred example.
Any elaboration as to why this verbose syntax is needed would be appreciated.
Jannis
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
Not sure if this is still an ongoing discussion, but I prefer to write
all new tags with a simple syntax that matches Python. There's no
real advantage in defining a unique, custom syntax for a template
tag.
All HTML authors are already familiar with Python's kwargs syntax,
since it exactly matches how HTML tags and attributes themselves
work. There's no great leap of difficulty going from:
<div class="something" style="something">
to
{% tag foo="something" bar="something" %}
Allowing for arbitrary custom syntax makes tags harder for HTML
coders, since they have to remember these special custom syntaxes
which they're not used to.