[Tutor] separating logic from html in web apps

Chris Lott chrisl@frodo.thethirdsector.com
Tue, 28 May 2002 16:57:16 -0800 (AKDT)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What programming I know has largely been in Cold Fusion, PHP and Perl
for system admin type tasks and some basic form CGI.I have repeatedly
been told how desirable it is to use a programming language like Perl
or Python that allows one to separate code from HTML in web
applications.

This is very counter-intuitive to me (probably because of the tools I
learned with).

For example, let's say that I have a db and I want to publish it in
five different formats for HTML, XML, WAP, RDF and who knows what
else. In the PHP way, I would have five different templates, or one
template with five conditional blocks, each of which output one of
these versions.

What would I save using Python and CGI or mod_python? I still have to
have five different conditional blocks or objects or something to
create the output, I've lost the utility to edit HTML in an editor
(which is nice occasionally) or to validate the code as it sits, and I
have to go through the process of escaping special characters for all
of my HTML output...

I don't get why it is better except in THEORY. But many things in
theory don't prove to be so in the real world. I am sure this is just
a misunderstanding on my part!

c
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: PGP Signed/Encrypted for Authentication/Privacy

iD8DBQE89Cdy1oth6FEEbP0RAtYpAJ9aOsqeWIVD7h1mnkE4RrJryxsBLwCfS9V7
GzJp5s0oTITjFGSwiWTFrk8=
=V9A+
-----END PGP SIGNATURE-----