Re: [SMARTY] Unofficial new feature patch for Smarty 2.1.1

From: Date: Mon, 20 May 2002 22:53:26 +0000
Subject: Re: [SMARTY] Unofficial new feature patch for Smarty 2.1.1
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4316@lists.php.net to get a copy of this message
Dave, I commend your efforts! However, Smarty already does most of these things: 1) Block capture. How is this any different then the {capture} function already in Smarty? 2) For loop Smarty's {section} loop can already accomodate everything you are doing here: {section name=counter loop=10 step=3} I am {$smarty.section.counter.index} years old!<br> {/section} 3) function count array You can already do this in Smarty. There were {$smarty.get|@count} values submitted through GET! If you feel inclined to assign something: {assign var="SmartyInternal" value=$smarty|@count} 4) Left Trim: This is shorthand for {$var|regex_replace:"!^\s+!":""} This could be something handy to put in the repository. 5) Right Trim This is shorthand for {$var|regex_replace:"!\s+$!":""} This could be something handy to put in the repository. 6) Trim You could use php trim, or make a wrapper to it (probably what this is?) {$var|trim} 7) URL Encode Smarty already does this: {$TestString|escape:"url"} Stealth Dave wrote:
Hello. Allow myself to introduce... myself. My name is David Still, and I'm a web site developer who's been using Smarty in an e-commerce project since 1.4.1. Over the past few months, I've created several plugins to expand Smarty's already exceptional functionality that I think other people would find useful. I also created a new function which requires a patch rather than a plugin. Most of the plugins are extremely simple: single function modifiers, but very useful (three trim functions and a URL encoder). Other functions, like block capture and count array, are more useful. But the best addition is one that I feel Smarty has needed for quite some time: a for loop. The patch is for a real for loop which assigns the counter in a variable which can be used by other functions. Currently, the only way to create a loop in smarty is by using either section or foreach, both of which require an existing array. The new forloop function has no such requirement. I needed it to create a page counter, but it is certainly useful for many other functions as well. You can find all of the plugins and the patch at http://www.wiskars.com/Smarty. The forloop patch requires Smarty 2.1.1. Any feedback would be greatly appreciated. One other thing, I'd like to submit these functions for inclusion in the next version of Smarty. Who do I need to contact about that? Thanks, - Dave
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.

« previous php.smarty.general (#4316) next »