Re: [SMARTY-DEV] template param syntax

From: Date: Tue, 16 Dec 2003 07:02:52 +0000
Subject: Re: [SMARTY-DEV] template param syntax
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1996@lists.php.net to get a copy of this message
Oops, I misunderstood and forgot to explain a very important point, you raised, sorry... Reminder example: {err "some text" fatal} > I just want to get Smarty accepting things like I mentioned > above, by dafult, so the only incompatibility would be that > instead of getting > > Fatal error: Smarty: [in index.tpl line 2]: > syntax error: expecting '=' after attribute name 'fatal' > (Smarty_Compiler.class.php, line 1474) in Smarty_Compiler > .class.php on line 2062 > > we's implicitly get equivalent behavior to as if we had > written > > fatal=1 So, I missed to correctly explain my stance about the issue you referred to as ordered parameter passing. I missed it most likely because that's important only in uncommon scenarios: in most cases, it's most likely enough to support only one such "unnamed" argument (preferably called $default or $unnamed, whatever). But, that'd be a pretty lame approach, and would probably anyway need extra work to enforce... Assumption: obviously, the quoted args are string literals, and the unquoted ones beginning with _alpha chars are bool flags. (The rest is garbage (syntax error), or perhaps those beginning with num chars may be treated as numeric literals.) Then, in case multiple such free-standing string arguments are passed to the template, like {err "some text" fatal "some extra text"} woud be equivalent with {err "some text" "some extra text" fatal} and the template processor would collect the strings into some $unnamed_string array, keeping their order. (Similarly, it could also collect any freestanding numeric literals, to some $unnamed_numbers, but supporting numbers this way would be a highly pathetic feature -- I just mention this for completeness.) Even supporting those multiple unnamed strings is something quite superfuous, usually, but it would be possibly simply cheaper than *not* supporting them... (as I hinted above). In some cases, though, even multiple unnamed strings could be *extremely* useful and would allow very flexible templates, like: {putlist "line 1" "line 2" "line 3" numbered} You see? With a very minor & compatible extension to the arg. passing syntax, Smarty could bite quiet a huge chunk of extra usability (and finally could even beat my own hacky template processor, hopefully... ;) ). Thanks for your patience, Sz.

« previous php.smarty.dev (#1996) next »