#11832: include tag with optional block argument (selective include feature)
-----------------------------+----------------------------------------------
 Reporter:  mpaolini         |       Owner:  nobody    
   Status:  new              |   Milestone:            
Component:  Template system  |     Version:  1.1       
 Keywords:  feature          |       Stage:  Unreviewed
Has_patch:  1                |  
-----------------------------+----------------------------------------------
 Sometimes, for clarity, an included template contains code for different
 parts of the parent.

 This patch allows an extra {{{block}}} optional argument to the include
 tag. If specified, only that particular block of the included template
 will be included.

 an example:

 base.html:
 {{{
 <head>
 {% include "table-include" "jscript" %}
 </head>
 <body>
 <table>
 {% include "table-include" "header" %}
 {% for row in rows %}
  {% include "table-include" "rowdata" %}
 {% endfor %}
 </table>
 </body>
 }}}

 table-include.html:
 {{{
 {% block jscript %}
 <script> <!- --> </script>
 {% endblock %}
 {% block header %}
 <tr><th>heading</th></tr>
 {% endblock %}
 {% block rowdata %}
 <tr><td>{{row.data}}</td></tr>
 {% endblock %}
 }}}

 Without this patch you would need three different included tepmlates like:
 table-include-js.html, table-include-header.html and table-include-
 rowdata.html making the whole thing less maintainable

 if the block in arg is not found maybe we should raise a
 {{{TemplateSyntaxError}}} (or maybe not)

 patch is just a proof of concept. Tests included

 comments welcome

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11832>
Django <http://code.djangoproject.com/>
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to