Am 19.09.2008 um 18:08 schrieb Armin Ronacher:
[snip]
>
> What's harder to fix is how the i18n integration translates filter
> arguments or gettext constants (those _("foo") thingies).  Currently
> that happens very often at node/object creation rather than node/
> object evaluation.  A good example for that problem is
> FilterExpression.__init__.  The translation would have to be moved to
> the resolve method in that case.  When would a language change between
> template compilation and rendering?  If the language changes each
> request which is a very common case on multilingual websites.

My patch treats _(x) as syntactic sugar for x|gettext - where  
`gettext = lambda x: x and ugettext(x) or u''`.

> Changing the parser to a more advanced system or making the template
> engine more consistent is not so important for the time being, but I
> want to raise a few situations I encountered where the behaviour is
> confusing:
>
>   - cycle arguments are delimited by spaces and each item can be an
>     expression (however if there is a comma involved somewhere, it
>     seems like the tag is interpreted as comma separated list of
> strings
>     which makes the 'cycle "foo", "bar", "baz"' yield unexpected
> results.
>   - On the other hand arguments for the url tag are comma delimited,
>     but whitespace after comma is not allowed.
>
>   - The group-by part of the regroup tag is an expression, but
> everything
>     else but a variable name returns unexpected results.  Furthermore
>     does this tag only work on dicts.  By the group-by part I'm
> refering
>     to the expression after the "by" keyword:
>
>       {% regroupy foo by bar as blah %}
>
>     bar is here treated as constant string, even though it's
> represented
>     as variable in the regroup node and in the syntax.
>
>   - Likewise ssi excepts one argument that looks like a variable, but
> is
>     treated as constant string.
>
> Tags to be excluded from the variable-as-string rule should be block
> and load because they represent neither variables nor strings.  The
> argument for block works like a label and the argument for load is a
> library.

I agree, a convention for tuples and literal strings would be really  
helpful. I had to work around the {% url %} viewname issue (that's  
why TokenStream.parse_string() takes bare=True). It's solved  
backwards compatible yet accepts properly quoted strings. Whitespace  
may occur between tokens but is discarded. {% regroup %} uses  
TokenStream.parse_expression(), so that should be fixed too. {% cycle  
%} is problematic because it accepts the legacy {% cycle a,b as c %}  
format but that should be curable.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to