On Fri, 2006-12-01 at 17:51 -0800, Paul Novitski wrote:
> > At 12/1/2006 02:22 PM, Richard Lynch wrote:
> >
> > Try 10 X as many for most templating solutions.
> 
> Ten times as many templates as there are pages on the site?  Wow, 
> that's a lot.  Fortunately I don't use any of those templating 
> solutions you're referring to, and excessive templates isn't a 
> problem for me.  My own software usually takes three templates per 
> page -- header, body, and footer, and the header and footer are 
> generally global throughout the site.  That seems quite reasonable to me.

This topic comes up so often... My template engine allows you to punt
any chunk of content you want to an extra template. Then when you
compile the page you get 1, yes, 1 php page that is directly accessed
from the browser. Thus, contrary to the kinds of template engines to
which Richard refers, my engine reduces the fstat call count while
keeping your content in nice maintainable and re-usable sized chunks.

layout.template
---------------

<html>
    <head><jinn:template path="layout/meta.template"/></head>
<body>
<jinn:template path="layout/header.template"/>
<jinn:template path="layout/leftPane.template"/>
<jinn:template path="layout/rightPane.template"/>
<jinn:template path="layout/content.template"/>
<jinn:template path="layout/footer.template"/>
</body>
</html>

layout/content.template
-----------------------

<div class="content">
    <div class="title"><jinn:title/></div>
    <jinn:main/>
</div>

contactUs.source
----------------

Blah blah blah blah blah blah... please contact us.

patterns.txt
------------

array
(
    'target'   => 'contactUs.php',
    'source'   => '//contactUs.source',
    'template' => '//layout.template',
    'title'    => 'Contact Us',
);

contactUs.php
-------------

Everything defined in patterns.txt compiled together such that the
<jinn:main/> tag is replaced by the source file. All <jinn:template/>
and <jinn:source/> tags are imported during compile time to produce a
single php file that IS the file accessed by visitors via their browser.

If there's no need to have dynamic code, this does a great job of
compiling static HTML files also... and I don't know many other template
systems that can compile their templates to statically accessible HTML
files.

NYAH, NYAH!

That said, in general my framework uses one source file for each class
(or two classes if it's a factory and what the factory produces)... so I
guess I save on content includes, and lose out on dynamic class
includes. But then, other than 5 or 6 core classes, if you don't use the
other classes, then they don't get loaded (on demand requests).

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to