Re: Reusing a child block in an inherited template

2008-04-25 Thread Filipe Correia

I'm now turned to using the workaround of extracting the block I want
to reuse to an additional file, and include every time I need it
(which is always on the same template inheritance line). This feels
like cheating though. It would be a lot cleaner if I could just
reference the base template's block, but I'm not finding any
documentation on this matter :\
Is there any alternative (cleaner) way to accomplish the same?

Cheers,
Filipe

On Apr 23, 7:35 pm, Filipe Correia <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm wondering if the following is possible with django templates. I
> would like to override a given parent block, while maintaining the
> contents of it's child block:
>
> base.html:
> {% block firstblock %}
> 
> Bla bla bla
> {% block secondblock %}  ble ble ble {% endblock %}
> 
> {% endblock %}
>
> inherited.html:
> {% extends "base.html" %}
> {% block firstblock %}
> 
> this is being overriden
> {% block secondblock %}  {{ block.super }}  {% endblock %}
> 
> {% endblock %}
>
> I have a case similar with this one, which is not working as I thought
> it would ( {{ block.super }}  is outputting nothing, instead of the
> value from the parent template). Might I be doing something wrong or
> is this the expected behavior?
>
> thanks,
> Filipe Correia
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~--~~~~--~~--~--~---



Reusing a child block in an inherited template

2008-04-23 Thread Filipe Correia

Hi,

I'm wondering if the following is possible with django templates. I
would like to override a given parent block, while maintaining the
contents of it's child block:

base.html:
{% block firstblock %}

Bla bla bla
{% block secondblock %}  ble ble ble {% endblock %}

{% endblock %}


inherited.html:
{% extends "base.html" %}
{% block firstblock %}

this is being overriden
{% block secondblock %}  {{ block.super }}  {% endblock %}

{% endblock %}


I have a case similar with this one, which is not working as I thought
it would ( {{ block.super }}  is outputting nothing, instead of the
value from the parent template). Might I be doing something wrong or
is this the expected behavior?


thanks,
Filipe Correia


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~--~~~~--~~--~--~---