public static function compile(&$context, $template, $name = 0) {
        if ((end($context['partialStack']) === $name) && (substr($name, 0, 14) === '@partial-block')) {
            return;
        }

        $tmpContext = $context;
        $tmpContext['inlinepartial'] = array();
        $tmpContext['partialblock'] = array();

        if ($name !== 0) {
            $tmpContext['partialStack'][] = $name;
        }

        $code = Compiler::compileTemplate($tmpContext, str_replace('function', static::$TMP_JS_FUNCTION_STR, $template));
        Context::merge($context, $tmpContext);
        if (!$context['flags']['noind']) {
            $sp = ', $sp';
            $code = preg_replace('/^/m', "'{$context['ops']['seperator']}\$sp{$context['ops']['seperator']}'", $code);
            // callbacks inside partial should be aware of $sp
            $code = preg_replace('/\bfunction\s*\(([^\(]*?)\)\s*{/', 'function(\\1)use($sp){', $code);
            $code = preg_replace('/function\(\$cx, \$in, \$sp\)use\(\$sp\){/', 'function($cx, $in)use($sp){', $code);
        } else {
            $sp = '';
        }
        $code = str_replace(static::$TMP_JS_FUNCTION_STR, 'function', $code);
        return "function (\$cx, \$in{$sp}) {{$context['ops']['array_check']}{$context['ops']['op_start']}'$code'{$context['ops']['op_end']}}";
    }
public static function compile(&$context, $template, $name = 0) {
        if ((end($context['partialStack']) === $name) && (substr($name, 0, 14) === '@partial-block')) {
            return;
        }

        $tmpContext = $context;
        $tmpContext['inlinepartial'] = array();
        $tmpContext['partialblock'] = array();

        if ($name !== 0) {
            $tmpContext['partialStack'][] = $name;
        }

        $code = Compiler::compileTemplate($tmpContext, str_replace('function', static::$TMP_JS_FUNCTION_STR, $template));
        Context::merge($context, $tmpContext);
        if (!$context['flags']['noind']) {
            $sp = ', $sp';
            $code = preg_replace('/^/m', "'{$context['ops']['seperator']}\$sp{$context['ops']['seperator']}'", $code);
            // callbacks inside partial should be aware of $sp
            $code = preg_replace('/\bfunction\s*\(([^\(]*?)\)\s*{/', 'function(\\1)use($sp){', $code);
            $code = preg_replace('/function\(\$cx, \$in, \$sp\)use\(\$sp\){/', 'function($cx, $in)use($sp){', $code);
        } else {
            $sp = '';
        }
        $code = str_replace(static::$TMP_JS_FUNCTION_STR, 'function', $code);
        return "function (\$cx, \$in{$sp}) {{$context['ops']['array_check']}{$context['ops']['op_start']}'$code'{$context['ops']['op_end']}}";
    }
public static function compile ( & $ context , $ template , $ name = 0 ) { if ( ( end ( $ context [ 'partialStack' ] ) === $ name ) && ( substr ( $ name , 0 , 14 ) === '@partial-block' ) ) { return ; } $ tmpContext = $ context ; $ tmpContext [ 'inlinepartial' ] = array ( ) ; $ tmpContext [ 'partialblock' ] = array ( ) ; if ( $ name !== 0 ) { $ tmpContext [ 'partialStack' ] [ ] = $ name ; } $ code = Compiler :: compileTemplate ( $ tmpContext , str_replace ( 'function' , static :: $ TMP_JS_FUNCTION_STR , $ template ) ) ; Context :: merge ( $ context , $ tmpContext ) ; if ( ! $ context [ 'flags' ] [ 'noind' ] ) { $ sp = ', $sp' ; $ code = preg_replace ( '/^/m' , "'{$context['ops']['seperator']}\$sp{$context['ops']['seperator']}'" , $ code ) ; // callbacks inside partial should be aware of $sp $ code = preg_replace ( '/\bfunction\s*\(([^\(]*?)\)\s*{/' , 'function(\\1)use($sp){' , $ code ) ; $ code = preg_replace ( '/function\(\$cx, \$in, \$sp\)use\(\$sp\){/' , 'function($cx, $in)use($sp){' , $ code ) ; } else { $ sp = '' ; } $ code = str_replace ( static :: $ TMP_JS_FUNCTION_STR , 'function' , $ code ) ; return "function (\$cx, \$in{$sp}) {{$context['ops']['array_check']}{$context['ops']['op_start']}'$code'{$context['ops']['op_end']}}" ; }
compile a template into a closure function

@param array<string,array|string|integer> $context Current context of compiler progress.
@param string $template template string
@param string|integer $name partial name or 0

@return string $code compiled PHP code
compile a template into a closure function