Habari\HiEngineParser::hi_if PHP Метод

hi_if() публичный Метод

Replace an if tag section with its PHP counterpart
public hi_if ( array $matches ) : string
$matches array The match array found in HiEngineParser::process()
Результат string The PHP replacement for the template tag
    function hi_if($matches)
    {
        list($void, $eval, $context) = $matches;
        $eval = preg_replace_callback('/([\'"]).*?(?<!\\\\)\\1/i', array($this, 'string_stack'), $eval);
        $eval = preg_replace_callback('/\\b((?<!::)[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff.]*(?!::))\\b/i', array($this, 'var_replace'), $eval);
        $eval = preg_replace('/(?<!=)=(?!=)/i', '==', $eval);
        $eval = str_replace(array_keys($this->strings), $this->strings, $eval);
        $context = preg_replace('/\\{hi:\\?else\\?\\}/i', '<?php else: ?>', $context);
        $output = '<?php if (' . $eval . '): ?>';
        $output .= $this->process($context);
        $output .= '<?php endif; ?>';
        return $output;
    }