Hacker News new | ask | show | jobs
by fookyong 5974 days ago
maybe I've misunderstood, but this seems to advocate mixing inline HTML and php logic - isn't that a huge step backwards in terms of web software architecture? I thought we were all using the MVC model by now...

My head just hurts thinking how utterly unmaintainable all that spaghetti code must be.

2 comments

Not really. You can still separate MVC style. Templates have always had some display logic, which is ok. What you don't want is intermixed application logic.
In my opinion this "fuzzy" separation is exactly what frameworks like Django (and many existing PHP MVC frameworks) tries to avoid - they specifically disallow things like arithmetic in their templating language for this reason. As soon as you get more than one person working on a site, you're going to have an overly ambiguous demarcation point between the presentation and the logic layers and it's going to wreak havoc on the development process. It will take an enormous amount of discipline to have a parallel design/code workflow.

Does this offer any benefits to XML comprehension beyond syntactical sugar to allow echo avoid the use of quotes and to remove the god-awful <?php ?> syntax (which puts it at par, at the very best, in my opinion)? Does it handle XML syntax errors gracefully? Can you do native transformations on bound variables, for example, or do any more sophisticated XML DOM-ish tag functions? The post doesn't mention anything about any of these issues, which is where the real advantage would lie. If any of that were possible, you could put the browser DOM (and validation) one step closer to the application logic. As far as I can tell this just attempts to ambiguate the VC in MVC, where Django tries to replace V with T (template).

As far as I'm concerned this only increases the squinty-eyed "WTF" factor between PHP and other languages.

I definitely agree. I'm moving my Rails app to the mustache template language so that I'm forced to keep every single piece of logic (and I do mean that. Mustache allows only conditional statements, for each statements, and the outputting of variables) out of my HTML templates.
The article claims that it's stored in DOM and can manipulated as such. To me the big win though is that using this means things should get escaped properly by default.
I might be crazy but I swear I didn't see that they addressed everyone of my concerns... wtf?
This doesn't say that at all. The rendering code you write needs to be modular as well, and has quite a bunch of logic built into it (even when all the model and controller logic is separate.) So when you write your renderers as classes or functions, that is when you realize the benefit of XHP.