Pet peeve about proper indenting of HTML
Posted: Fri Apr 14, 2006 10:29 am
I have a pet peeve. This pet peeve is that all HTML code be nicely formatted, with proper indenting, wrapping, etc. This is nice HTML code:
This is icky HTML code:
The only other type of code is crushed code:
So, this pet peeve causes me to gravitate towards code 1 and 3. The problem is, in order to fulfill this need, I've reverted back to string concatenation.
The $this->_nl() calls used to nicely format the code.
Templating would probably be the best idea, but to properly format the templates...
...you get icky HTML. Someone, please convice me that nice formatting of HTML is not necessary (even though it makes looking at the source a joy).
Code: Select all
<div class="StoryDescription">
<div>
<a href="/s.php?a=nnamdic&s=queengreen" class="linktitle">The Queen of the Green</a>
by <a href="/a.php?a=nnamdic" class="linkauthor">Nnamdi Chukwuneke</a>
Reviews: <a href="/book.php?a=nnamdic&s=queengreen" class="reviews">queengreen</a>
</div>
</div>Code: Select all
<div id="des">
<div id="des_chapter">
</div>
<div id="des_global">
<div id="des_global_author"> <b class="des_label">By</b>: <a href="/thewritingpot/a.php?a=nnamdic">Nnamdi Chukwuneke</a> </div>
<div id="des_global_info">
<b class="des_label">Info</b>: <a href="/thewritingpot/s.php?a=nnamdic&s=queengreen&c=1&action=info" >More Information</a>
</div>
</div>
</div>Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>Wikipedia's Status</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" type="text/css"href="/wikistatus/css/default.css" /></head><body><h1>Wikipedia's Status</h1><div id="ImportantServices"><table cellspacing="0"><tr><th>Read Speed</th><th>Write Speed</th></tr><tr><td style="color:#070;">Fast</td><td style="color:#070;">Fast</td></tr></table></div><div id="LesserServices"><table cellspacing="4"><tr><th>Watchlist Speed</th><td class="message" style="color:#070;">Fast</td></tr><tr><th>Search Speed</th><td class="message" style="color:#070;">Fast</td></tr><tr><th>Recent Changes Speed</th><td class="message" style="color:#070;">Fast</td></tr></table>Code: Select all
function paintImportantServices(&$services) {
if (empty($services)) return;
echo $this->_nl() . '<div id="ImportantServices">';
echo $this->_nl(1) . '<table cellspacing="0">';
echo $this->_nl(1) . '<tr>';
foreach ($services as $key => $value) {
$service =& $services[$key];
echo '<th>';
echo $this->htmlentities($service->getName()) . ' Speed';
echo '</th>';
}
echo '</tr>';
echo $this->_nl() . '<tr>';
foreach ($services as $key => $value) {
$service =& $services[$key];
echo '<td style="color:'.$service->getSpeedColor().';">';
echo $this->htmlentities($service->getSpeedName());
echo '</td>';
}
echo '</tr>';
echo $this->_nl(-1) . '</table>';
echo $this->_nl(-1) . '</div>';
}Templating would probably be the best idea, but to properly format the templates...
Code: Select all
<div style="float:right;width:30%;margin-left:1em;margin-bottom:1em;
border-bottom:1px solid #999;background:#FFF;">
<h2>Author Information</h2>
<ul>
<li>Screenname: {$var.author->getScreenname()|default:"<i>None</i>"}</li>
<li>Joined: {$var.author->getJoined()}</li>
{if $var.author->getSiteURL()}<li><a href="{$var.author->getSiteURL()}">{*
*}{$var.author->getSiteName()|default:$var.author->getSiteURL()}</a></li>{/if}
<li>Email: {$var.author->getEmailToCloaked()}</li>
{if $var.author->isPublished()}
<li>Total Words: {$var.author->getWordCount()|number_format}</li>
<li>Total Stories: {$var.author->getStoryCount()|number_format}</li>
<li>Total Chapters: {$var.author->getChapterCount()|number_format}</li>
{/if}
<li><a href="{$_dir}/book.php?sub=1&a={$var.a}&s=personal">Review this Author</a></li>
<li><a href="{$_dir}/book.php?a={$var.a}&s=personal">Reviews about this Author</a></li>
<li><a href="{$_dir}/book.php?a={$var.a}">Reviews to Author</a></li>
</ul>
</div>