quotes, escaping and translation of string literals handled inconsistently in templates
|Reported by:||Antti Kaihola||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
The Django template syntax sometimes accepts literal strings only in double quotes, whereas in other situations also single quotes work. Including a quote in a string by escaping it with a backslash doesn't work everywhere. Implementing SmileyChris's suggestion to #5756 (filter expressions as arguments for the
include tags) is difficult because of incosistencies in the underlying mechanisms.
String literals are dealt with in the FilterExpression and Variable classes in [source:django/trunk/django/template/__init__.py django/template/__init__.py]. The classes contain two different and overlapping approaches to unquoting string literals. FilterExpression embeds unquoting in the regex which parses filter expressions, and Variable takes a more "manual" approach.
With some modifications the following could be achieved:
- both single and double quoted strings work everywhere
- filters as template tag arguments easier to implement (see #5756)
- escaping quotes works consistently
- code re-use (DRY)
The challenge is to not lose performance.