Web development with Python 3.1

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Thu Oct 29 09:54:15 CET 2009


Dotan Cohen a écrit :
>> What do you mean by "in the middle of the page"? Do you mean, for instance,
>> the behavior of "middle.php" in the following PHP example:
>>
>> <?php
>>
>> include_once("beginning.inc.php");
>>
>> include_once("middle.php");
>>
>> include_once("end.inc.php");
>>
>> ?>
>>
>> Is that what you are after?
>>
> 
> Yes, that is what I am after.

Django's templating system has an "include" statement, but also 
something you don't have in PHP : an "extends" statement. Yes, template 
inheritance. This means that you can define the general basic layout for 
all your site in one "base" template, and make your other templates just 
fill the "blanks" you defined in the base template.

FWIW, I'm using Django has an example but quite a few other templating 
systems have this "template inheritance" feature one way or another...

> For instance, if one were to look at the
> source code of http://dotancohen.com they would see "<!-- / HEADER
> -->". All the HTML up to that point was output by bigginin.inc.php.
> Similarly, near the end exists "<div class="bottomfiller">", all the
> code from there is generated by end.inc.php. These two files are
> included in every page of the site.

And ? Do you really thing we'd all be wasting time using templating 
systems too dumb to do even such a simple thing ???

Perhaps this might better answer your questions:
http://docs.djangoproject.com/en/dev/topics/templates/#id1




More information about the Python-list mailing list