You can verify the templates by parsing them without rendering (using
an empty dataset).  That way you can give immediate feedback to your
users when they edit them.  As for xhtml compliance, ColdFusion isn't
compliant either.

If that's not for you, it's simple to write a command processor that
will handle ${command:name:val;name2;val2} style commands.  Build an
abstract parser that just does the extraction and delegates processing
to a collection of command handlers that are registered at runtime.
We've also used this technique for certain tasks where a templating
engine isn't appropriate (typically because of the complexity).  A
psuedo-example:

<table>
<tr>
  <th>Recent News</th>
  <th>Press Releases</th>
</tr>
<tr>
  <th>${docList;count:3}</th>
  <th>${docList;typeId:42;count:3}</th>
</tr>
</table>

The basic idea for the engine is to find a ${ string, find the
matching } character, extract what's in between, take the first
section as a command name, turn the rest into name/value pairs, and
then use the command name to invoke the correct command handler's
"process" method with arguments matching the name/value pairs.  The
return value of the process method is then used to replace the ${...}
expression in the result, and processing moves on to the next value.
If you're algorithm just searches for and processes the first
instance, you can even use the substitution values to inject more
dynamic expressions that will be processed on the next round.

We haven't implemented any sort of looping or conditional constructs
to the language, but for simple injection and formatting, it's served
us very well.

cheers,
barneyb

On 10/30/06, Jeff Chastain <[EMAIL PROTECTED]> wrote:
> Barney,
>
> I have looked at ClearSilver before, I just have not liked its syntax.  I 
> like for the templates to be able to be verified on their own and ClearSilver 
> is not xhtml compliant.  I am not sure if Smarty is or not.
>
> Thanks for the pointer.
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258475
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to