Re: [SMARTY-DEV] Patch?

From: Date: Thu, 29 Jan 2004 10:57:10 +0000
Subject: Re: [SMARTY-DEV] Patch?
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2076@lists.php.net to get a copy of this message
On Tue, Jan 27, 2004 at 03:56:50PM -0500, Sean Coates wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hello Smarty dev list, > > I'd like to submit a patch. In what format would you like this? > > I've attached my cvs diff -u from an anonymous checkout, > today (I > don't think I have the necessary CVS karma for a commit -- plus, I'm new > to smarty-dev, and thought I should run it by the list, anyway). > > This patch adds a new config member > $Smarty->graceful_undefined_constants that defaults to TRUE (preserving > backwards-compatibility). > When false, the @ error suppressor is omitted from a > $smarty.const.CONSTANT_HERE construct (in the compiled template). > > This works hand-in-hand with the $Smarty->error_reporting member. I think constants in the template should behave like template-variables: trigger an E_NOTICE if an undefined constant is accessed. I'm against adding yet another configuration-value for that. At the moment "{$smarty.const.VAR}" is compiled to "@constant(VAR)" . As an alternative i only see something like: (defined(VAR) ? constant(VAR) : trigger_error(..., E_NOTICE)) for each constant in the template. With that we would bloat the template significantly if lots of constants are used. But we only have to do this for constants whose name is not available at compile-time: {$smarty.const.$foo} for example. {$smarty.const.FOO} could be compiled to simply FOO and would behave correctly (emitting an E_NOTICE if undefined) i think the vast majority in templates has constant names so we would even shrink the compiled template a little ("FOO" vs. "@constant('FOO')"). this could compensate the cases where we have to emit a longer construct like: (defined($const=$this->_tpl_vars['foo']) ? constant($_const) : trigger_error(..., E_NOTICE)) vs. @constant($this->_tpl_vars['foo']) just an idea. greetings messju > Let me know if I did something wrong, or if I plain overlooked an easier > way to do this. Or if I'm just confusing/confused (-: > > Thanks, > Sean Coates > sean@php.net

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