Re: [SMARTY-DEV] Suggestion: make template commands case insensitive
| From: | messju mohr | Date: | Thu, 24 Apr 2003 11:26:20 +0000 |
| Subject: | Re: [SMARTY-DEV] Suggestion: make template commands case insensitive | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1259@lists.php.net to get a copy of this message | ||
On Wed, Apr 23, 2003 at 01:52:09PM +0200, Wom.bat wrote:
> > 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
okay. i won't go as far as you suggested (suppressable warning and stuff),
but i think i will make _get_plugin_filepath() look for mixed-case filenames
if it does not find the lowercase one.
mixedcase-plugin-filenames will be marked as deprecated at the next
stable release then.
the support for mixedcase-plugin-filenames (including the search in
_get_plugin_filepath()) will be abandoned a release later then.
any objections from anywhere?
greetings
messju
> 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