I just reformatted the default layout of my CakePHP application. I eliminated as much in-line html as possible by putting almost everything inside the html helper methods.
It was fun, but I'm wondering what benefit I've gained from this exercise, if any?
<?php
$output = implode("\n", array(
$html->docType(),
$html->tag('html', implode("\n", array(
$html->tag('head', implode("\n", array(
$html->charset(),
$html->tag('title', 'Title For App'),
$html->css('css', NULL, array('media' => 'screen,print')),
$html->css('print', NULL, array('media' => 'print')),
$html->script(array('cufon', 'jquery','external'))
))),
$html->tag('body', implode("\n", array(
$html->tag('div', $content_for_layout, array('id' => 'wrapper')),
$html->scriptBlock('Cufon.now();')
)))
)), array('xmlns' => 'http://www.w3.org/1999/xhtml'))
));
echo $output;
?>
I suppose at least it looks nice and compact, and is pretty readable. What pitfalls should I be aware of in this scenario? Should I be aware of any speed issues?
I like it — and I don't.
I guess I need convincing one way or the other.
If you're wondering, the implodes put nice line breaks in the html when viewing the source.
<?php ?>
tags. – Ginzburg