p(HP) t(emplate) a(ttribute) l(anguage)
a ZPT like templating system in PHP
Modeled after the Zope Page Templates (ZPT) ptal uses standard HTML-Tag with special attributes to define templates.
Benefit: The templates can be edited in any HTML-Editor and preview as normal HTML
Example simple Page Template:
<h3 ptal:content="title" class="h3">The Title</h3>
<blockquote ptal:content="description">The Description</blockquote>
<h1 ptal:replace="body">The <b>Body</b></h1>
generic syntax
<tag attribute="value" ptal:[macroname]="[macro params]">
content with <b>markup</b> and further
<span ptal:[othermacro]="params">ptal markup</span>
</tag>
'[macroname]' and '[othermacro]' are names for macro-functions that take some fixed params and the ptal-params, and return whatever they like.
The return will replace the complete <tag></tag>
(macros can return the tag-markup and content but don't need to)
The processing of the page need to start from the outside in - this is to make loops etch possible: A ptal-tag might call a for-in like macro that takes the enclosed ptal-markup as template for the loop-output
ptals make 'content-filtering' and transformation via enclosing ptals possible
<span ptal:make_js="">[the whole reset of content]</span>
-> make_js could now mangle the whole page into js write('') calls and return that
!! ptals might even return more ptal mark-up !!
-> carefull to prevent deadlocks..
-> this could be handled by introducing a 'level of recursion' setting:
the return of a ptal will be checked for ptals, but only n-times
=> each ptal expansion will always return a string w/o ptal markup (can be empty)
Due to a limitation in the current regex-based ptal parser it handles nested tags incorrectly:
<span ptal:foreachin="elem list">
<span ptal:write="elem"></span>
multipied with 2 gives:
<span ptal:multiply="elem 2"></span>
<br>
</span>
Workaround is to use different tag (HTML or other) to nest ptals.
<p ptal:foreachin="elem list">
<span ptal:write="elem"></span>
multipied with 2 gives:
<span ptal:multiply="elem 2"></span>
<br>
</p>
Powered by Traumtank
© 2002 martin@traumwind.de