RE: breaking from loops
| From: | travis at dawnstar dot org | Date: | Wed, 27 Feb 2002 15:42:35 +0000 |
| Subject: | RE: breaking from loops | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2860@lists.php.net to get a copy of this message | ||
It certainly could be rewritten that way! Of course, by the time I
realized I could specify loop iterations right in the template, I had
already rewritten it in a completely different way. :-)
cheers,
Travis
On Wed, 27 Feb 2002, Andrei Zmievski wrote:
> On Wed, 27 Feb 2002, Travis Low wrote:
> > In my particular case, I'm porting a calendar screen to Smarty. After
> > writing calendar screens in a variety of templating languages, I've
> > concluded that the cleanest way to visually represent a Gregorian
> > month is something like:
> >
> > for i = 1 to 6
> > {
> > for j = 1 to 7
> > {
> > display days of month, padding rows as necessary.
> > }
> > break out if we've displayed all the days
> > }
> >
> > The decision to display a Gregorian calendar month in grid format is a
> > presentational decision, not a business decision. The desire to break
> > out is motivated by the desire to not display a blank row. So I don't
> > think it's appropriate for the data-driven PHP script to provide a row
> > count for the loop. I'd rather decide in the template.
> >
> > Even without this example, I think it would be a good idea to allow
> > this capability. I'm not a designer, but it doesn't seem far-fetched
> > that a designer might want to loop to create a design, but break on
> > some dynamically determined value. Since I can't think of a good
> > example, don't expect much of a debate from me on this point. :-)
>
> Why can't this logic be rewritten as:
>
> for i = 1 to 6
> {
> if not displayed all days
> {
> for j = 1 to 7
> {
> display days of month
> }
> }
> }
>
> -Andrei
>
> "I think it would be a good idea." -- Mahatma Gandhi,
> when asked what he thought of Western civilization...
>