Drupal 7 Themeing - template.tpl.php vs template.php - variables
The disadvantage is you leak a lot of PHP code processing Drupal inner structures to the template file.

I would preprocess $content in template.php to expose a simple array of strings as a custom variable:

$colors = $content['product:title']['#product']-&gt;field_taxonomy_color['und'];
$colorNames = Array();
for ($x = 0; $x &lt; count($max_length); $x++) {
  $colorNames[$x] = $colors[$x]['taxonomy_term']-&gt;name;
}
$variables['color_names'] = $colorNames;


Then the template code could be:

&lt;?php if ($color_names): ?&gt;
&lt;div id="color-wrapper"&gt;
  &lt;?php foreach ($color_names as $cn)
    print '&lt;div class="color"&gt;' . $cn  . '&lt;/div&gt;'; ?&gt;
&lt;/div&gt;
&lt;?php endif; ?&gt;