Chris Czub wrote:
[SNIP]
> The "extends" block means, roughly, to take index.html and replace any 
> blocks inside of it with the ones defined in the current file, photos.html.

You sound like you know what you want already, but thought I'd mention a couple 
of alternatives anyhow. You could do something similar to this:

base_page.tt
<div id="head">
  [% PROCESS head %]
</div>
<div id="content">
  [% PROCESS content %]
</div>

index.html:
[% BLOCK head %]
   <h1>CatConnoisseur.com</h1>
[% END %]
[% BLOCK content %]
   <p>Welcome to the front page of my site!</p>
[% END %]
[% PROCESS base_page.tt %]

photos.html:
[% BLOCK content %]
<p>Here are some cats!</p>
<ul>
<li><img src="/img/cat1.jpg"/></li>
</ul>
[% END %]
[% PROCESS base_page.tt %]

Obviously it requires 3 pages instead of 2, so that could be out of your 
requirements, but if it's something you plan on using over and over again, it 
probably isn't that big of a deal. With a little more code in the base 
index.html you could use just two files too. All pages that extend it would 
still be very simple. Example:

index.html:
<div id="head">
   [% TRY; PROCESS head; CATCH file; THROW $error IF !error.info.match('head: 
not found') %]
   <h1>CatConnoisseur.com</h1>
   [% END %]
</div>
<div id="content">
   [% TRY; PROCESS content; CATCH file; THROW $error IF 
!error.info.match('content: not found') %]
   <p>Welcome to the front page of my site!</p>
   [% END %]
</div>

photos.html:
[% BLOCK content %]
<p>Here are some cats!</p>
<ul>
<li><img src="/img/cat1.jpg"/></li>
</ul>
[% END %]
[% PROCESS index.html %]


Those things said, I don't think you have a bad idea for extending via block 
replacement. One more tool in the toolbox.

-- Josh

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to