Re: Smarty feature proposal: context aware template tags

From: Date: Wed, 28 Nov 2001 11:03:21 +0000
Subject: Re: Smarty feature proposal: context aware template tags
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2069@lists.php.net to get a copy of this message
At 11:57 AM 11/28/01 +0100, Anders Janson wrote:
Ivo Jansch wrote: Hello, I use a lot of custom functions and custom compiler functions in a Content Management System that I am building around Smarty. Now in some cases, I want tags to be 'context aware', by which I mean that tags should know that they are used 'inside' other tags. This kind of nesting happens when a tag needs to render a subtemplate, in which other tags could be used. I was thinking if it would be possible to keep some sort of 'tag stack' in which one can see what tags are currently being rendered. For example, if I have a tag named {foo} and the handler for this tag renders a template that contains a tag {bar}, than inside the handler function for {bar}, $smarty->m_tagstack should contain array("foo","bar"); I wish Smarty had custom start and end tags!!
I agree! Along with built-in Multi-lingual capabilities this is at the top of my wishlist... then I can implement my {table} function like everyone wants it: {table loop=$foo} {* Cell contents here *} {/table}
We could , for example, write custom tags like "bar", which would only be allowed to be used in a certain context, perhaps only within a {foo}...{/foo} block. Or render different output, depending on the context (but would this be good design?).
This would be cool! Cheers! Peter. -- Maple Design - http://www.mapledesign.co.uk

« previous php.smarty.general (#2069) next »