public static function renderLayout($layout, $content, $vars = array(), $dirs = null)
    {
        $dirs = $dirs ?: self::get('atomik.dirs.layouts');
        if (is_array($layout)) {
            foreach (array_reverse($layout) as $l) {
                $content = self::renderLayout($l, $content, $vars, $dirs);
            }
            return $content;
        }
        
        // allows rendered files to dynamically add layouts
        $appLayout = self::delete('app.layout');
        self::set('app.layout', array($layout));
        
        do {
            $layout = array_shift(self::getRef('app.layout'));
            self::fireEvent('Atomik::Renderlayout', array(&$layout, &$content, &$vars, &$dirs));
            $vars['contentForLayout'] = $content;
            $content = self::render($layout, $vars, $dirs);
        } while (count(self::get('app.layout')));
        
        self::set('app.layout', $appLayout);
        return $content;
    }