#9173: Conditional content of template blocks
---------------------------------+-----------------------------------------
     Reporter:  while0pass       |                    Owner:  nobody
         Type:  New feature      |                   Status:  new
    Component:  Template system  |                  Version:  master
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Someday/Maybe
    Has patch:  1                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+-----------------------------------------

Comment (by alimony):

 I was thinking about this the other day. How about something like:

 {{{
 parent.html

 <table>
   <tr>
     <td>{% block firstcol %}{% endblock %}</td>
     <td>{% block secondcol %}{% endblock %}</td>
     {% block thirdcol if block.child %}<td>{{ block.child }}</td>{%
 endblock %}
   </tr>
 </table>
 }}}

 Which would introduce a `{{ block.child }}` thing similar to `{{
 block.super }}`

 And also conditional blocks in general, in which you can specify:

 {{{
 {% block title if post.title %}My title{% endif%}
 }}}

 Which is the equivalent of, but shorter than:

 {{{
 {% block title %}
   {% if post.title %}
     {{ post.title }}
   {% else %}
     {{ block.super }}
   {% endif %}
 {% endblock %}
 }}}

 What do you think of all the above?

--
Ticket URL: <https://code.djangoproject.com/ticket/9173#comment:9>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.8fb76d5835b620e590867f64aa8d32ff%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to