#1522: [patch] Allow template tags to accept hardcoded strings with spaces
-----------------------------+----------------------------------------------
Reporter: SmileyChris | Owner: adrian
Type: defect | Status: new
Priority: normal | Milestone:
Component: Template system | Version:
Severity: normal | Resolution:
Keywords: |
-----------------------------+----------------------------------------------
Comment (by [EMAIL PROTECTED]):
Here's a patch to use this in decorators like include_tag etc:
{{{
#!diff
Index: django/template/__init__.py
===================================================================
--- django/template/__init__.py (revision 3116)
+++ django/template/__init__.py (working copy)
@@ -749,7 +749,7 @@
def generic_tag_compiler(params, defaults, name, node_class, parser,
token):
"Returns a template.Node subclass."
- bits = token.contents.split()[1:]
+ bits = list(token.split_contents())[1:]
bmax = len(params)
def_len = defaults and len(defaults) or 0
bmin = bmax - def_len
}}}
This makes it much easier to pass strings with spaces and/or template
variables to tags like so:
{{{
{% my_tag "hello {{ world }}" %}
}}}
regards
Matthew Flanagan
--
Ticket URL: <http://code.djangoproject.com/ticket/1522>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates
-~----------~----~----~----~------~----~------~--~---