At 11/28/2006 05:05 AM, Satyam wrote:
May I invite you to check http://satyam.com.ar/pht/? This is a
project I started some time ago to help me produced HTML in a more
clean and efficient way. Usually, producing good HTML involves
running a sample output through some HTML validator or looking at
the HTML and checking it out by hand, which, of course, requires
good formatting to make it understandable. In the case of too
dynamic HTML (meaning, output can vary widely) it is impossible to
produce enough samples of all the possible outputs to get them checked out.
So, my idea was to embed HTML into the language itself so that the
final output could be checked at 'compile time' and even before,
using the standard tools provided by the IDE (even just matching
braces goes a long way into checking for missmatched HTML tags).
Satyam,
That's an impressive bit of work, congratulations.
It's interesting to see someone spend such energy merging PHP logic
with HTML. I've gone in the opposite direction, separating the two
as much as possible. My own CMS merges content with HTML based on
CSS-style selectors so that the logic layer of my applications
doesn't need to know -- or contain -- the full details of the
markup. I find this a natural and agreeable extension of the move to
separate HTML markup from CSS presentation and JavaScript behavior.
It's interesting to note that for all your effort to generate good,
clean HTML, you're still able to generate a div nested inside a table:
<table for ( $i=1; $i < 10; $i++) {
<div {
&style = ($i & 1?"odd":"even");
<tr {
Ouch! According to the spec, this is an illegal structure:
http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1
Your pre-compiler has ensured that all your tags are well-formed, but
it doesn't ensure that you've followed the rules of correct
markup. Perhaps a future iteration of your software will incorporate
more HTML structural rules and will give you precompiler errors in such cases.
You write:
So, we have two well structured languages, one is procedural (any
flavor of C, JavaScript, PHP, Perl, etc.), the other descriptive.
Their blocks are quite compatible: to start with, they nest nicely
within each other. If an XML block is contained within an if()
block, it has to be completely within it, the boundaries of their
blocks should not overlap.
Help me understand the relevance of this statement. A very common
pattern in a mixed logic/HTML script goes like this:
echo '<ul>';
foreach (array as item)
{
echo '<li>item</li>';
}
echo '</ul>';
In these cases the boundaries of the HTML block do in fact overlap
the boundaries of the foreach() logic block.
And, of course, I would appreciate any comment on the project,
EXCEPT that you use template engines and that you do not generate
HTML directly. I've heard that and it is completely missing the
point so, please, spare me that one. At one point or another plain
HTML has to be generated.
Unless I'm missing the boat, it seems to me that the primary
advantage of your precompiler is that it enables you to close HTML
tags simply by closing braces, a convention policed by your
pre-compiler and the PHP interpreter itself, so that you'll get
pre-compiler or interpreter errors for incorrect closure instead of
waiting for the W3C validator to check your work. I don't mean to
minimize the significance of your accomplishment, but personally I
don't find generating accurate markup to be a great problem. I'm a
careful hand-coder, and true to the topic of this thread I find that
neatly-indented HTML helps me validate my own markup. Online
validators help me catch any errors I miss.
What I find to be a much greater problem is the human readability of
logic code when HTML is mixed throughout. Your innovation is helpful
here, as you're nearly making HTML tags into PHP key words,
eliminating some of the literal quoting that makes PHP+HTML so
tiresome. However, even with your pre-compiler the messy quotes are
still there on the attribute level. And, stepping back, you're
perpetuating the embedding of markup with logic so that it will still
take a PHP programmer to modify the markup of one of your pages. Do
you not see the advantage in separating the two layers?
Again, in spite of this criticism I'm impressed with your effort. Good work!
Regards,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php