You are here

private function HamlRenderer::renderAttributes in Sassy 7

* Renders element attributes

1 call to HamlRenderer::renderAttributes()
HamlRenderer::renderOpeningTag in phamlp/haml/renderers/HamlRenderer.php
* Renders the opening tag of an element

File

phamlp/haml/renderers/HamlRenderer.php, line 67

Class

HamlRenderer
HamlRenderer class. Provides the most common version of each method. Child classs override methods to provide style specific rendering. @package PHamlP @subpackage Haml.renderers

Code

private function renderAttributes($attributes) {
  $output = '';
  foreach ($attributes as $name => $value) {
    if (is_integer($name)) {

      // attribute function
      $output .= " {$value}";
    }
    elseif ($name == $value && in_array($name, $this->minimizedAttributes) && ($this->format === 'html4' || $this->format === 'html5')) {
      $output .= " {$name}";
    }
    elseif (in_array($name, $this->minimizedAttributes)) {

      // $value is a variable, isset is called to make sure E_NOTICE is not thrown
      if (preg_match("", trim($value))) {
        $output .= "<" . "?php if(isset({$value}) && !empty({$value})): ?" . "> {$name}={$this->attrWrapper}<" . "?php echo {$value}; ?" . ">{$this->attrWrapper};<" . "?php endif; ?" . ">";
      }
      else {
        $output .= "<" . "?php if({$value}): ?" . "> {$name}={$this->attrWrapper}<" . "?php echo {$value}; ?" . ">{$this->attrWrapper};<" . "?php endif; ?" . ">";
      }
    }
    else {
      $output .= " {$name}={$this->attrWrapper}{$value}{$this->attrWrapper}";
    }
  }
  return $output;
}