Re: [SMARTY-DEV] Suggestion: make template commands case insensitive
| From: | Wom.bat | Date: | Wed, 23 Apr 2003 11:52:09 +0000 |
| Subject: | Re: [SMARTY-DEV] Suggestion: make template commands case insensitive | ||
| References: | 1 2 3 4 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1258@lists.php.net to get a copy of this message | ||
> hmm.
>
> as i would want to see case-insensitive functions: the plugin-name
> will be made to lowercase at registration-time. anywhere where the
> plugin-name is used inside smarty it is also made lowercase before it
> is looked up inside smarty. this is the most consistent to me.
that's what I would do, too. store the funcion name in lower cases, and
transform the function name written in templates into lower case format
before it is looked up. I don't know how you are storing these functions,
but I guess it's an associative array with the function name as the index.
So just make the index lower-case would do the job, wouldn't it?
> but then the studdly-capped name will not be reconstructable from
> smarty anymore (comparable to get_class() that always returns
> lowercase classname). and i definately want to avoid having to
> readdir() through the plugins-dir to find a case-insentively matching
> php-file. that's not an option either.
>
> so for sake of simplicity and consistency i would like to break BC
> here a little.
>
> the lowercase-plugin-name would become some kind of canonical
> plugin-name. so the file where it's implementation resides would have
> to have the canonical name (the 'function.' and the '.php' are also
> case-sensitive anyway :).
aaaaah... I see... you couldn't find out the file name if it's case
sensitive!?...
hmhmhmhmmh... *think*
In my opinion, this issue is worth breaking BC. It's just more intuitive if
blocks, functions, modifiers etc are case insensitive, just like in PHP.
BUT there IS the possibility of keeping BC: if I do a {doSomethingPlease} in
my template, and function.dosomethingplease.php is not found, you could do a
readdir on the plugins dir, SAVE this dir list (when a developer does this
'mistake' once, he's likely to do this with all his plugins, so you need to
do the readdir only once), then look up for function.doSomethingPlease.php,
and if this one is found, you print out a WARNING. You could introduce a new
variable $force_plugins_case_sensitivity, which is set to FALSE in the next
release, but to TRUE in the releases after. If this var is true, the
readdir() is executed and a warning is displayed, if it is not, Smarty just
won't find the plugin, and abort. Maybe it would be useful to have a second
variable to specify whether Smarty should print this warning or not, too
(set to NO WARNING for the next release, set to WARNING in the release
after, and in the third release, case sensitivity is disabled completely...
along with a big, fat note on this in the next NEWS and CHANGELOG files)
Just my 2 cents,
David
P.S: gnaarh... one week on vacations, and my english is getting weak...
> but i'll only break this if there is a minimal amount of consensus. :)
>
> > Regards,
> > David
> >
> >
> >
> > --
> > Smarty Development Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>