/** * Ends a block. If inside an <?Chano::extend()?><?Chano::endextend()?> * section and the block has content, store that content for later use. If * not, check if the current block is extended, if it is output the extended * content, else output the content of the current block. */ static function endblock() { $content = ob_get_clean(); $has_content = trim($content) !== ''; $is_extended = isset(self::$blocks[self::$active_block]); if (self::$inside_extend) { if (!$is_extended && $has_content) { self::$blocks[self::$active_block] = $content; } } else { if ($is_extended) { if ($has_content) { echo str_replace(self::super, $content, self::$blocks[self::$active_block]); } else { echo self::$blocks[self::$active_block]; } unset(self::$blocks[self::$active_block]); } else { if ($has_content) { echo $content; } } } self::$active_block = null; }
static function block($name) { ob_start(); self::$active_block = $name; return self::block_is_on(); }