Re: [SMARTY-DEV] Re: cvs commits, passes smoke tests

From: Date: Fri, 20 Dec 2002 17:36:24 +0000
Subject: Re: [SMARTY-DEV] Re: cvs commits, passes smoke tests
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-471@lists.php.net to get a copy of this message
Hmm, recursion has a problem. Smarty currently parses the tokens out with regular expressions. You can't do regular expressions recursively, at least not that would work with every possible syntax. This will require a stacking mechanism that finds the inner-most valid set of parenthesis and works its way outward. It will take some additional programming and testing, but it's probably the method to go with. I could also do a hack that will work only one or two levels deep, or work with most simpler syntaxes, but that's not really what I'd like to do. Unless someone has a better idea, please share! Monte On Fri, 2002-12-20 at 01:41, André Rabold wrote: > Sorry for reporting errors ;-) > > {if strlen(trim($var)) > 4} > ... > {/if} > > Doesn't work anymore after your commit. It seems you cannot use functions as > parameter for functions anymore. The compiled script has syntax (!!) errors. > > Does {$foo[$index]->getVar("bar")} and > {$foo[sectionindex.index_next]->getVar("bar")} work? Haven't tested it yet > but I really need this and haven't found any comment on this in your > posting. > > Have fun, > André > > > > "Monte Ohrt" <monte@ispi.net> schrieb im Newsbeitrag > news:1040343207.16659.144.camel@lena.ispi.prv... > > Ok, I've had my fill of regex work for awhile, that is enough to drive > > one mad :-) > > > > the latest commit passes my smoke tests, which you can get here: > > > > http://www.phpinsider.com/temp/smarty_smoketest.tar.gz > > > > I tried to cover as much as I could, but I'm sure there is more that > > could be added. > > > > The regular expressions are cleaned up and cascade nicely, so a lot of > > syntax that didn't previously work now does. It is _way_ more managable > > now, I don't get such headaches looking at them :-) I tried strange > > stuff like passing objects as parameters to modifiers and it works fine. > > About the only thing you can't do is pass an object as a parameter to an > > object. That is only be design, it's possible but I didn't see a reason > > to support it. You can call objects in objects just fine though, such as > > ($foo->bar->foobar('blah')) > > > > Here are some examples from the smoke test, and they work: > > > > {$foo} > > {$foo|upper} > > {$foo|upper|spacify} > > {$foo|spacify:"^^"} > > {$foo|@count} > > {$foo|default:"no"} > > {$foo|truncate:6:"...":true} > > > > {$afoo.one} > > {$afoo.two} > > {$afoo.one|upper} > > {$afoo.one|upper|spacify} > > {$afoo.one|spacify:"^^"} > > {$afoo.one|@count} > > {$afoo.one|default:"no"} > > {$afoo.one|truncate:6:"...":true} > > {$afoo.$bar} > > > > {#foo#} > > {#foo#|upper} > > {#foo#|upper|spacify} > > {#foo#|spacify:"^^"} > > {#foo#|@count} > > {#foo#|default:"no"} > > {#foo#|truncate:6:"...":true} > > > > > > {#foo#} > > {#foo#|upper} > > {#foo#|upper|spacify} > > {#foo#|spacify:"^^"} > > {#foo#|@count} > > {#foo#|default:"no"} > > {#foo#|truncate:6:"...":true} > > > > {$ofoo->blah} > > {$ofoo->foo('bar')} > > {$ofoo->foo("bar")} > > {$ofoo->foo("$foo bar")} > > {$ofoo->foo("one","two")} > > {$ofoo->foo("one","two","three")} > > {$ofoo->foo("one $foo","two","three")} > > {$ofoo->foo("one $foo","two $foo","three")} > > {$ofoo->foo("one","two","three","four")} > > {$ofoo->foo('one $foo','two $foo','three')} > > {$ofoo->foo('one')|upper} > > > > {ffoo var="foo"} > > {ffoo var="foo" var2="blah"} > > {ffoo var=$foo} > > {ffoo var=truey} > > {ffoo var=$foo|upper} > > {ffoo var="foo"|upper} > > {ffoo var=$ofoo->foo("$foo bar")} > > {ffoo|upper var=$foo} > > > > {section name=sec loop=$sfoo} > > {$sfoo[sec]} > > {$sfoo[sec.index]} > > {$sfoo[sec.index_next]} > > {$sfoo[sec.index_prev]} > > {$sfoo[sec.iteration]} > > {$sfoo[sec.first]} > > {$sfoo[sec.last]} > > {$sfoo[sec.rownum]} > > {$sfoo[sec.loop]} > > {$sfoo[sec.total]} > > {$sfoo[sec.show]} > > {$sfoo[sec]|upper} > > {$sfoo[sec]|upper|spacify} > > {$sfoo[sec]|spacify:"^^"} > > {$sfoo[sec]|@count} > > {$sfoo[sec]|default:"no"} > > {$sfoo[sec]|truncate:6:"...":true} > > {/section} > > > > {$smarty.section.sec.index} > > > > {if $foo}{/if}(end) > > {if $foo eq "bar"}foo is bar{/if}(end) > > {if is_array($foo)}foo is array{else}foo is not array{/if}(end) > > {if $foo gt 4}$foo is gt 4{/if}(end) > > {if ($foo gt 4)}$foo is gt 4{/if}(end) > > {if ( $foo gt 4 )}$foo is gt 4{/if}(end) > > {if $foo and not $bar}foo and not bar{/if}(end) > > {if !$bfoo}not bfoo{else}bfoo{/if}(end) > > {if 4 is div by 4}div by 4{else}not div by 4{/if}(end) > > {if 3 is div by 4}div by 4{else}not div by 4{/if}(end) > > {if 3 is div by 4 or ( 3 eq 3 )}blah{/if}(end) > > {if (3 is div by 4) or ( 3<="bah"|upper )}woohoo{/if}(end) > > {if in_array("my $bar", $afoo)}is in{else}is not in{/if}(end) > > {if $ofoo->foo()}is in{else}is not in{/if}(end) > > {if in_array($ofoo->foo("two"), $afoo)}is in{else}is not in{/if}(end) > > > > {$smarty.now} > > {$smarty.const._MY_CONST} > > > > {$foo|spacify:"|"} > > {$foo|spacify:"|"|upper} > > {$foo|spacify:"$foo"|upper|default:"|"} > > > > {section name=sec loop=$sfoo} > > > > {$ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":t > rue)} > > {$nfoo->ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:" > ...":true)} > > {/section} > > > > {ffoo|spacify:"|"|upper var="lalala"} > > {ffoo|spacify:" my spaces "|upper var="lalala"} > > {ffoo|spacify:"!@#$%^&*()_+=-\|]["|upper var="lalala"} > > > > > > {if !$nfoo->ofoo->foo("blah blah")}not blah{else}blah{/if}(end) > > > > > > Monte > > > > -- Monte Ohrt <monte@ispi.net>

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