Think/Template.php
protected function compiler($tmplContent)
    {
        //模板解析
        $tmplContent = $this->parse($tmplContent);
        // 还原被替换的Literal标签
        $tmplContent = preg_replace_callback(
            '/<!--###literal(\d+)###-->/is',
            [$this, 'restoreLiteral'],
            $tmplContent
        );
        if (C('TMPL_STRIP_SPACE')) {
            /* 去除html空格与换行 */
            $find = ["~>\s+<~", "~>(\s+\n|\r)~"];
            $replace = ['><', '>'];
            $tmplContent = preg_replace($find, $replace, $tmplContent);
        }
        // 添加安全代码
        $tmplContent = '<?php defined(\'APP_PATH\') || exit(-1);?>'.$tmplContent;
        // 模版编译过滤标签
        Hook::listen('template_filter', $tmplContent);

        return $tmplContent;
    }
protected function compiler($tmplContent)
    {
        //模板解析
        $tmplContent = $this->parse($tmplContent);
        // 还原被替换的Literal标签
        $tmplContent = preg_replace_callback(
            '/<!--###literal(\d+)###-->/is',
            [$this, 'restoreLiteral'],
            $tmplContent
        );
        if (C('TMPL_STRIP_SPACE')) {
            /* 去除html空格与换行 */
            $find = ["~>\s+<~", "~>(\s+\n|\r)~"];
            $replace = ['><', '>'];
            $tmplContent = preg_replace($find, $replace, $tmplContent);
        }
        // 添加安全代码
        $tmplContent = '<?php defined(\'APP_PATH\') || exit(-1);?>'.$tmplContent;
        // 模版编译过滤标签
        Hook::listen('template_filter', $tmplContent);

        return $tmplContent;
    }
编译模板文件内容

@param mixed $tmplContent 模板内容

@return string
@throws BaseException