Re: [SMARTY] Re: passing an array to an included template

From: Date: Fri, 03 May 2002 13:22:56 +0000
Subject: Re: [SMARTY] Re: passing an array to an included template
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4024@lists.php.net to get a copy of this message
You right, you should be separating business logic from view. IMHO, the section names should be part of the content assigned from the business logic, not something assigned within the template. Jens Lehmann wrote:
That said, I think it makes no sense to have a plugin which assigns values to an array, since any plugin would operate in a predeterministic way; any array you assign through a plugin will always have the same number of elements, so why make it an array?
I don't quite understand. Why do you think any array assigned in a template has always the same number of elements?
Array assignment & population is definitely something that should happen outside the template...
I described my reasons why I don't want to assign in outside the template. Smarty wants to seperate code and layout, that's why it makes in some cases no sense to assign the array within the PHP-code. Another argument is that there is already an assign-function, but it can't handle arrays.
The flexibility of a Smarty often makes it tempting to write a plugin every time you can't do something with out-of-the-box smarty functionality, but people really need to be careful that they're not just creating some new variant of {PHP}.
You're right. But at least anything which is really needed to seperate logic and view should be a part of Smarty. In the cycle-function Smarty already has to deal with arrays. Maybe by dealing more with arrays in the future such a function makes still more sense.
Smarty and templating engines in general are meant to separate business logic from the 'view'. The fact that you can't do complicated PHP-esque things in a smarty template shouldn't be viewed as a limitation that should be hacked around with a plugin. Instead, people need to remember that this is the POINT of a templating tool.
The point is to seperate logic from view. What can I do else than writing a plugin in my case?
Anyhow, I just wanted to get that off my chest since I've been noticing a lot of odd feature requests, and Monte and Andrei have been doing a great job at keeping Smarty a templating API and not PHP-based hypertext processor.
Imho Andrei and Monte really do a great job. Maybe I'm not really objective in this matter, because I'm the one who had the problem. :-) Jens
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.

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