[prev in list] [next in list] [prev in thread] [next in thread] 

List:       smarty-dev
Subject:    Re: [SMARTY-DEV] Block extensibility?
From:       messju mohr <messju () lammfellpuschen ! de>
Date:       2003-03-26 11:52:29
[Download RAW message or body]

On Wed, Mar 26, 2003 at 12:43:06PM +0100, Nico Sabbi wrote:
> >
> > i don't know which one you mean, but i'm pretty sure it is not anyway.
> >
> > > In this case, can I write blocks such as  the following  one?
> > > {if}
> > > {elsif}*        repeated an unlimited (and not know a-priori) number of
> times
> > > {else}
> > > {/if}
> >
> > blocks in smarty a very restricted. for something like the above you
> > would have to use your own compiler functions. see:
> > http://smarty.php.net/manual/en/plugins.compiler.functions.php
> >
> > (hint) maybe you don't need to patch smarty, since you can:
> > register_compiler_function('myif', 'myif_open);
> > register_compiler_function('/myif', 'myif_close);
> >
> > then you can implement a closing and an opening function (and
> > optionallyy my_else etc., of course) and write in your template:
> > {myif ...}  ...  {/myif}
> >
> 
> 
> And in this case how can I instruct Smarty that {myelse} is part of {myif}
> {/myif} syntactic block ?

you can not. the smarty parser is regexp-based and very slim. it does
not do these syntactic checks. you'll notice that when you have errors
in your template (like a closing {/if} whithout an opening one). the
template-compiler does not raise an error, but the template has
php-syntax-errors.

so you'll have to maintain your own stack of myif-blocks and check
inside the myelse-function whats the top-open-myif it belongs to.


 
> Thanks.

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic