Monday, August 15, 2011

Commenting in html, tpl.php etc.

I came across a very nice commenting convention in the drupal zen theme template files:

They close all of the class and id marked sections with

<!-- /.{classname} -->


<!-- /#{idName} -->



<tr class="genesis-page-header-row">

is closed  with

</tr><!-- /.genesis-page-header-row -->


This is nice enough in helping you to keep track of what's going on when editing the code. However, it is invaluable in understanding what might have gone wrong when examining pages in a "modern" inspector.

For example, here's how that section looks in Safari 5.1:

Drupal image upload

making it clear that the you and the browser both agree on the <tr> being terminated by this </tr> (if you and the browser don't agree, it probably indicates that something has gone awry).