public function render_layouts($html, $vars = array())
 {
     if (strpos($html, 'perch:layout') !== false) {
         $s = '/<perch:layout[^>]*>/';
         $count = preg_match_all($s, $html, $matches);
         $renderer = $this->layout_renderer;
         if ($count > 0) {
             if (is_array($matches[0])) {
                 foreach ($matches[0] as $match) {
                     $Tag = new PerchXMLTag($match);
                     $attrs = $Tag->get_attributes();
                     if (is_array($vars)) {
                         $vars = array_merge($vars, $attrs);
                     } else {
                         $vars = $attrs;
                     }
                     $out = $renderer($Tag->path(), $vars, true);
                     $html = str_replace($match, $out, $html);
                 }
             }
         }
     }
     return $html;
 }