Re: if statements
[email protected] (Dan Libby)
| Newsgroups | php.template |
|---|---|
| Message-ID | <[email protected]> |
I think ifs are somewhat evil. The same could be done with:
Your search found {products_total} {match_plural}.
Thus, the plurality logic remains in the PHP code. One argument against
this is that it does not internationalize well.
I don't have a good answer for that offhand.
-dan
Andrei Zmievski wrote:
> Perhaps, the general feeling is that 'if' statements in templates are
> bad. Here's how they are useful though (taken from a template written
> using SmartTemplate class):
>
> <i>Your search found {products_total}
>
> {if: products_total != 1}
> matches.
> {/if}
> {if: products_total = 1}
> match.
> {/if}
> </i>
>
> To do this using only dynamic sections would make it look something
> like this:
>
> <i>Your search found {products_total}
>
> {section: products_total_is_1}
> matches.
> {/if}
> {section: products_total_is_more_than_1}
> match.
> {/if}
> </i>
>
> Then the developer would need to explicitly hide one of the sections.
> And what if there is another place on the page where some output will
> depend on where products_total is greater than 5, for example? Another
> effort on part of developer is needed.
>
> So, what are your thoughts? Are 'if' statements good or evil?
>
> -Andrei
>
> Nobody tried to design Windows - it just grew in random
> directions without any kind of thought behind it.
danda.vcf
(text/x-vcard, 304 B)
begin:vcard n:Libby;Dan tel;work:650-210-2356 x-mozilla-html:TRUE url:http://www.epinions.com org:Epinions.com;Engineering adr:;;;;;; version:2.1 email;internet:[email protected] title:Morlock note:We're hiring at epinions.com. Engineers, site designers, QA -- we need you. fn:Dan Libby end:vcard