I've used ClearSilver (www.clearsilver.net) in a few CF apps with
great success.  I've never used Smarty, but I haven't found
ClearSilver much lacking.  It's definitely a templating engine; it's
got no brains, but tha'ts exactly what we were looking for.  You can
build macros, use includes, and all that stuff that you'd expect, or
you can do simple runtime string evaluation if you don't want to allow
any sort of external dependancies.  The syntax isn't as tight as the
${...} notation, but it's not overly cumbersome.  Here's an example
(of your loop from above):

<?cs each:c = contacts ?>
  phone: <?cs var:c.phone ?><br />
  fax: <?cs var:c.fax ?><br />
  cell: <?cs var:c.cell ?><br />
<?cs /each ?>

cheers,
barneyb

On 10/30/06, Jeff Chastain <[EMAIL PROTECTED]> wrote:
> I am in need of a template engine similar to Smarty (PHP) for ColdFusion?  I 
> have not found such a thing yet.  Does it exist?
>
> If not, how would you go about writing a parser in ColdFusion that could take 
> a template like this ...
>
> --------------------------------------------------
>
> The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
>
> The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
>
> Example of accessing server environment variable SERVER_NAME: 
> {$smarty.server.SERVER_NAME}
>
> The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
>
> variable modifier example of {ldelim}$Name|upper{rdelim}
>
> <b>{$Name|upper}</b>
>
> {section name=sec1 loop=$contacts}
>         phone: {$contacts[sec1].phone}<br>
>         fax: {$contacts[sec1].fax}<br>
>         cell: {$contacts[sec1].cell}<br>
> {/section}
>
> --------------------------------------------------
>
> .... and turn it into CFML like this ...
>
> --------------------------------------------------
>
> The current date and time is <cfoutput>#dateFormat(Now(), 'y-m-d')# 
> #timeFormat(Now(), 'H:m:s')#</cfoutput>
>
> The value of global assigned variable $SCRIPT_NAME is 
> <cfoutput>#SCRIPT_NAME#</cfoutput>
>
> Example of accessing server environment variable SERVER_NAME: 
> <cfoutput>#CGI.SERVER_NAME#</cfoutput>
>
> <cfoutput>The value of #config.ldelim#$Name#config.rdelim# is 
> <b>#config.Name#</b></cfoutput>
>
> <cfoutput>variable modifier example of 
> #config.ldelim#$Name|upper#config.rdelim#</cfoutput>
>
> <cfoutput><b>#ucase(name)#</b></cfoutput>
>
> <cfloop from="1" to="#arrayLen(contacts)#" index="contactPtr">
>         <cfoutput>phone: #contacts[contactPtr].phone#<br></cfoutput>
>         <cfoutput>fax: #contacts[contactPtr].fax#<br></cfoutput>
>         <cfoutput>cell: #contacts[contactPtr].cell#<br></cfoutput>
> </cfloop>
>
> --------------------------------------------------
>
> Regular expression find/replace comes to mind first, but I am obviously 
> looking for the best performance as well.
>
> Any suggestions?
>
> Thanks.
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:258466
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to