Re: Var Templates

From: Date: Wed, 16 Apr 2003 18:58:54 +0000
Subject: Re: Var Templates
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1202@lists.php.net to get a copy of this message
Tom Wrote: > I think you misunderstood my request... The feature I am requesting > would only be part of the parser, and only needed to be run once. > basically I am looking for the *possibility* of extending backtrics... > so that it would do the following to config vars > var1 = "hello $myvar, welcome" > with (in compiled templates) > var1 = "hello ". $this->_tpl_vars['myvar'] .", welcome" Tom, I still think your example suggests a standard template treatment: config.tpl --------------- {assign var=value1 value=hello $myvar, welcome} usage.tpl --------------- {include file=config.tpl} I'm sure that you will object: this is NOT the same as config files. I agree: templates and config files are very different beasts. That's what makes config files small, fast and simple. Templates are where expansions SHOULD take place. >> What I think COULD be useful is extending the include function to >> allow for partioning of a template resource into sections that can be >> individually loaded (much like config files). > > I have no need for this, you might, which is why there are so many > problems regarding what smarty should contain My idea for template "portions" was naively inspired as a step towards unifying templates and config files to meet what I saw as your needs. Mea Culpa. I have to admit, after your last post I'm now confused as to what you *DO* need config vars for at all, especially since you want to use them from PHP. I gather that the above example wouldn't work for you just because you want to use the exanded form of the 'templated' vars from your php code. I don't think it is unreasonable to ask why you don't just use straight PHP code in this case. After all, what you are asking for is really an indirection around the simplest possible PHP code of all: $myvar = 'test'; $var1 = "hello $myvar welcome"; Sometimes you just don't need the hammer! If you MUST have it templated, how about this: config.tpl ------------------- $var1 = "hello $myvar welcome"; config.php ------------------- $smarty->assign('myvar', 'test'); eval($smarty->fetch('config.tpl')); You see, I'm not trying to say you don't have a valid need; I'm suggesting that there are already plenty of ways to get to where you want to go without changing anything in the core or introducing any new concepts. Good luck and have fun! xo boots ps. I liked your freudian slip: "backtrics" :) __________________________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo http://search.yahoo.com

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