BTW, What do you think about template system or at least class to handle the generation of the output?If we'll use such solutions it'll be much more easy to keep consistency
Le 10/26/2010 06:30 PM, Alan Smith a �crit :
> Template systems mean learning a new "language" and we don't want this
> project to have any barriers to entry. Generating the HTML is extra code and
> to edit the HTML you'd have to know how the generator works. Plain HTML with
> the PHP embedded eliminates any of these hassles and is the most
> flexible/fast.
Not sure it's most flexible, btw. I'm used to deal with this kind of
templates, and i can say, obviously, that's a BAD idea: this mean adding
a lot of logic in the templates, and tend to complexify the whole solution.
In PHP, you can have a look to the excellent TWIG, by fabien potencier,
and this article is a very good starting point:
http://fabien.potencier.org/article/35/templating-engines-in-php-follow-up.
I really think there is a value added by the fact of using a template
management system. It's really not that hard to learn, and simplify *a
lot* the comprehension of those ones.
Cheers,
Alex
I must admit that I prefer to rely on template and logic-free systems,
because I have seen some really hard and crappy uses of
php-based-templates.
But, if you already have a working system, we could continue that way, I
was just advocating about my POV about that.
Cheers,
Alex
One of the best thing about templating systems is the ability to extend
templates, via blocks. if any of you have done some django coding, or
using jinja2, you know what I'm talking about.
For the other ones, that are not familiar with this concept, we have
basically a "extends" directive, and a "block" one. So it's possible to
extend a already existing template, and just change parts of it.
Then, we do have some interesting things, like a value that's
auto-magically set to odd or even when looping on values, and other
things like that.
Another useful thing is a standardized way to handle objects and arrays
for instance (named hash or dicts in other languages). so, to access
$array['key1']['key2'], and $object->key1->key2, you use the same
syntax, that could be {{ var.key1.key2 }}, so no need to worry about
that here.
You also can auto-escape your variables before using it, this kind of stuff.
Then, that's not huge advantages, but I think they make code simple to
read and maintain.
Of course, we have access to all interesting stuff we could do in php
itself, but it's adding some facilities.
For more informations on templating systems I'm talking about, you can
have a look to Twig and Django:
http://www.twig-project.org/book/02-Twig-for-Template-Designers
http://docs.djangoproject.com/en/1.2/topics/templates/
Hope it's helpful !
Cheers,
Alexis
>
> Please enlighten me.
>
> Alan
>
Okay, no problems, it's a really old discussion and people can't agree
on that, no problems :)
> (Keep in mind that we want a low barrier to entry with this project. The
> easier it is to modify, the more people will help.)
I was thinking about the templating system about something to low the
barrier, but if you said it will raise it up instead, it seems better to
dont use one.
> Alex, if you wish to write up some code that extolls the virtues of Twig,
> send it to me. I will then write matching php code and it will be a fair
> comparison. I'm doing this so that any fear you have of plain php will be
> alleviated, not so I can say "my way is better than yours".
In fact, I'm not a Twig fanatic, and I've stopped writing PHP because
some things like that are not obvious and lead sometimes to have really
ugly quick and dirty code. Well, no problems, if we try to keep the
separation of the 3 tiers clear, it will work :)
No problems about the "who have the biggest one", I dont care, and it's
a really interesting discussion BTW.
> Know that if there's some Twig feature you love (or can't live without) we
> can always code it ourselves instead of using a full-featured system.
As I've said, there is an excellent article from Fabien Potencier (the
Symfony guy) about that: have a look, I agree a lot with him:
http://fabien.potencier.org/article/34/templating-engines-in-php
Alex
>
> Alan
>
Alex