Re: [SMARTY-DEV] compiler-block functions (again, sorry)

From: Date: Fri, 10 Jan 2003 15:22:35 +0000
Subject: Re: [SMARTY-DEV] compiler-block functions (again, sorry)
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-514@lists.php.net to get a copy of this message
On Fri, Jan 10, 2003 at 10:00:38AM -0500, Andrei Zmievski wrote: > I would do it this way, but rather provide a stack, similar to block > functions, so that you can inspect it to see what functions enclose > youru current one. yes. the stack is also useful to be able to acces the $tag_args, that where passed to the block when opening it, on the closing side. i just wanted to make it as simple as possible in the first place. i thougt if i minimize the implications that come with it, i raise the chance you accept my patch :) for now the compiler-plugins have to maintain their own stack(s). i will have a look, if i could bring this inside _compile_compiler_tag(). regards messju > On Fri, 10 Jan 2003, M Mohr wrote: > > Hello, > > > > I suggested support for compiler-block functions a while ago. > > Advanced template programmers would be able build their own while and > > for loops und things like switch and case statements. > > > > My first approach was ugly and extended the api by another plugin-type. > > That was bad. > > > > I want to come up with a more simpler patch now: > > > > RCS file: /repository/smarty/Smarty_Compiler.class.php,v > > retrieving revision 1.145 > > diff -r1.145 Smarty_Compiler.class.php > > 477a478,486 > > > if ($tag_command{0} == '/') { > > > /* handle closing tag */ > > > $this->_compiler_tag_start = false; > > > $tag_command = substr($tag_command, 1); > > > } else { > > > /* handle opening tag */ > > > $this->_compiler_tag_start = true; > > > } > > > > > > The only impact on backwards-compatibility is, that without this > > patch "{/func}" raised an error and is now accepted by the compiler. > > This should not be a problem. :) > > > > Additionly the compiler sets a flag, wether the function was called as > > an opening or a closing tag. Now the compiler-function can ask > > $smarty->_compiler_start_tag to see, how it was called and generate code > > accordingly. > > > > The compiler-function does not have to check this flag, of > > course. Non-block compiler-functions simply ignore this flag, as they > > do now. :) > > > > With that functionality, it should be possible to write (medium > > easily) functions like "foreach", "section" or "if" as > > compiler- > > plugins. I don't think it is necessary to have these basic constructs > > as plugin, but it shows the power of the simple compiler-block-patch > > above. > > > > Used in the right way it could empower the template-programmer to > > provide powerful functions to his/her designers that could lead to > > even simpler templates, as they are possible now. > > > > I would love to see this in smarty-cvs. > > > > have fun > > messju > > > > -- > > Smarty Development Mailing List (http://smarty.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -Andrei > http://www.gravitonic.com/ > > As I was going up the stair, I met a man who wasn't there. > He wasn't there again today. I wish, I wish he'd stay away. > -Hughes Mearns > > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

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