Re: [SMARTY-DEV] Bug in Smarty Compiler concerning constants?

[email protected] (Oliver Jones)
Newsgroups php.smarty.dev
Organization Deeper Design Limited
Message-ID <[email protected]>
On Tue, 2005-03-08 at 07:26 -0800, boots wrote:
> Erk, no, I meant PHP constants simply aren't supposed to be producible
> as clear tokens from Smarty. I wasn't suggesting a new behaviour --
> that's the way it already is. You found a bug where they are being let
> through. 

I see.  Well then I will "correct" my code to avoid the bug.  Though
personally I think it makes the code look very ugly.  

> I can't speak for why it was included in the first place but  an
> interface onto constants is consistent with Smarty's conception of
> using data provided from outside. It also makes possible a more secure
> restricted environment where you don't want the possibility of leaking
> any non-passed information from PHP into the user templates. This
> prevents, amoung other things, common paths stored in constants (eg:
> SMARTY_DIR) from being accessible to template users.
> 
> I'm not a huge fan of the $smarty reserved var either, but I don't
> think we should make a special case for their handling for if tags.

Your reasoning is sound.  You are right, things should be explicitly
passed to smarty for use in the templates.  Though for the sake of code
cleanliness perhaps we should instead have some sort of facility to set
constants in the same manner as we set 'variables' with assign()
(perhaps an assign_constant() method).  That way the compiler could
inspect the constants map and treat them accordingly.

Just an idea.

Regards

--
                   Oliver Jones » Roving Code Warrior
   [email protected] » +64 (21) 41 2238 » www.deeperdesign.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.