Re: Is it better to echo or leave as html?

From: rush (pipa_at_rush.avalon.hr)
Date: 10/02/03


Date: Thu, 2 Oct 2003 08:13:41 +0200


"Jean-Marc Molina" <goa_pasdepourriel_@ifrance.com> wrote in message
news:blevkt$2bf$1@news-reader5.wanadoo.fr...
> Hi Rush,
>
> > I personaly prefere it when html and code are in completely separate
> files.
>
> Don't forget that a Template Engine is not supposed to separate PHP code
> from HTML but business logic from presentation logic.

There are different school of thoughts on this, and I do not prefer the one
you propose, while I accept that it works for you and that you prefer it.

I think Template engine purpose _is_ to separate html from code. And that
bussiness logic shoud be separated from presentation logic by organizing
your code in MVC, or MVP patterns where business logic goes into M. But it
is the code part that separates presentation logic and bussines, not
templates which are used to separate html which define pure visial
appearance, and code defines presentation logic. It is much clear in
languages that come with MVP out of the box, like Dolphin Smalltalk. There
you have View composer, where you paint the appearance of the GUI and it
gets stored as a resource. It is equivalent of html. Than there is
Presenter, which is pure code and contains "Presentation" logic. And there
is Model that contains bussines logic.

The idea that template purpose is to separate business logic from
presentation has lead to "dirty" templates which contain both code and html.
In this scenario code (not necessary a php code, but code with loops, ifs
and other constructs anyway), is embeded into the html template. Most
prominent and respected examples of such approach would be XML+XSLT and
Smarty.

Again, both approaches work and some people like one, and some people like
onother, but it is by no means such a clear cut, and just a single "proper"
way to approach things.

Thanks,

rush

--
http://www.templatetamer.com/


Relevant Pages

  • Re: Templating engine?
    ... > you force a certain tree like structure on the template? ... It's only with gross alterations like changing the template node ... files that sit in the same directory as the HTML templates they belong ... Just use the following to read this file in and separate and compile ...
    (comp.lang.python)
  • Re: "Best" coding practice?
    ... > The goal is not to seperate HTML and PHP, ... Using a loop inside your HTML is not a bad thing, ... MVC to separate presentation logic and bussines logic. ... and stuffing too much into template in order to handle ...
    (comp.lang.php)
  • Re: "Best" coding practice?
    ... > The goal is not to seperate HTML and PHP, ... Using a loop inside your HTML is not a bad thing, ... MVC to separate presentation logic and bussines logic. ... and stuffing too much into template in order to handle ...
    (alt.php)
  • Template Engine like Smarty
    ... There is a Template Engine for C like Smarty ... to separate the html from the C code? ...
    (comp.lang.c)
  • Re: is anyone here going to help me??? does anyone here know anything at all???
    ... I am very sure that if I post my broken template and they ... Until like three or four days ago, everything on my blog displayed ... The generic Google ad beneath the blog title box displayed perfectly. ... I tried to publish and got a broken HTML error. ...
    (rec.gambling.poker)