I'd like to propose the following changes to django.template. Some of  
them are partially or fully implemented in my patch[1] for #3544.
Which of these have a chance to land in 1.0 (assumed I provide a  
patch, docs and tests)?

1.) Allow recursive includes, #3544 [2]

2.) Add a template_cache to `Context`, accessible via  
Context.get_template and Context.select_template. Use this in  
IncludeNode, ExtendsNode, and inclusion_tag.

3.) Add a `loader` kwarg to Context to force use of a specific  
templateloader (something with a get_template() method). This would  
fix #2949 [3].
class PrefixLoader:
     def __init__(self, prefix_list):
         self.prefix_list = prefix_list
     def get_template(name):
         from django.template.loader import select_template
         return select_template(['%s/%s' % (prefix, name) for prefix  
in self.prefix_list])

tpl.render(Context({}, loader=PrefixLoader(['a', 'b', 'c'])))
This emulates select_template() for include and extends nodes.

4.) Extend with-tag syntax to allow

        {% with foo as x and bar as y and ... %}
and/or {% with foo as x, bar as y, ... %}

5.) Extend include-tag syntax to allow

        {% include "template" with foo as x and bar as y %}
and/or {% include "template" with foo as x, bar as y %}

This would be equivalent to {% with ... %}{% include ... %}{% endwith  
%}.

6.) Add an optional `separator_chars` argument to  
utils.text.smart_split and template.Token.split_contents that enables  
extra delimiters

 >>> map(str, smart_split('a, b,c ,d, e ,f', separator_chars=','))
['a', ',', 'b', ',', 'c', ',', 'd', ',', 'e', ',', 'f']
 >>> map(str, smart_split('a=1, b=2 , c = 3', separator_chars=',='))
['a', '=', '1', ',', 'b', '=', '2', ',', 'c', '=', '3']

and use this in url, cycle, with, etc.

7.) Add a {% sub "name" %}...{% endsub %} tag that populates  
Context.template_cache["name"] with its contained nodelist. {%  
include "name" %} would then be used to render it.

[1] http://code.djangoproject.com/attachment/ticket/ 
3544/3544.contexttemplatecache.2.diff
[2] http://code.djangoproject.com/ticket/3544
[3] http://code.djangoproject.com/ticket/2949


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to