Cml\Service\Blade::display PHP Method

display() public method

抽象display
public display ( string $templateFile = '' ) : mixed
$templateFile string 模板文件
return mixed
    public function display($templateFile = '')
    {
        $options = $this->initBaseDir($templateFile);
        $compiler = new BladeCompiler($options['cacheDir'], $options['layoutCacheRootPath']);
        $compiler->directive('datetime', function ($timestamp) {
            return preg_replace('/(\\(\\d+\\))/', '<?php echo date("Y-m-d H:i:s", $1); ?>', $timestamp);
        });
        $compiler->directive('hook', function ($hook) {
            return preg_replace('/\\((.*?)\\)/', '<?php \\Cml\\Plugin::hook("$1"); ?>', $hook);
        });
        $compiler->directive('urldeper', function () {
            return '<?php echo \\Cml\\Config::get("url_model") == 3 ? "&" : "?"; ?>';
        });
        $compiler->directive('get', function ($key) {
            return preg_replace('/\\((.*?)\\)/', '<?php echo \\Cml\\Http\\Input::getString("${1}");?>', $key);
        });
        $compiler->directive('post', function ($key) {
            return preg_replace('/\\((.*?)\\)/', '<?php echo \\Cml\\Http\\Input::postString("${1}");?>', $key);
        });
        $compiler->directive('request', function ($key) {
            return preg_replace('/\\((.*?)\\)/', '<?php echo \\Cml\\Http\\Input::requestString("${1}");?>', $key);
        });
        $compiler->directive('url', function ($key) {
            return preg_replace('/\\((.*?)\\)/', '<?php echo \\Cml\\Http\\Response::url("${1}"); ?>', $key);
        });
        $compiler->directive('public', function () {
            return '<?php echo \\Cml\\Config::get("static__path", \\Cml\\Cml::getContainer()->make("cml_route")->getSubDirName()."public/");?>';
        });
        $compiler->directive('token', function () {
            return '<input type="hidden" name="CML_TOKEN" value="<?php echo \\Cml\\Secure::getToken();?>" />';
        });
        $compiler->directive('lang', function ($lang) {
            return preg_replace('/\\((.*?)\\)/', '<?php echo \\Cml\\Lang::get("${1}"); ?>', $lang);
        });
        $compiler->directive('config', function ($config) {
            return preg_replace('/\\((.*?)\\)/', '<?php echo \\Cml\\Config::get("${1}"); ?>', $config);
        });
        $compiler->directive('assert', function ($url) {
            return preg_replace('/\\((.*?)\\)/', '<?php echo \\Cml\\Tools\\StaticResource::parseResourceUrl("${1}"); ?>', $url);
        });
        $compiler->directive('acl', function ($url) {
            return preg_replace('/\\((.*?)\\)/', '<?php if (\\Cml\\Vendor\\Acl::checkAcl("${1}")) : ?>', $url);
        });
        $compiler->directive('endacl', function () {
            return '<?php endif; ?>';
        });
        foreach ($this->rule as $pattern => $func) {
            $compiler->directive($pattern, $func);
        }
        $finder = new FileViewFinder([$options['templateDir'], $options['layoutDir']]);
        $finder->addExtension(trim(Config::get('html_template_suffix'), '.'));
        $factory = new Factory($compiler, $finder);
        header('Content-Type:text/html; charset=' . Config::get('default_charset'));
        echo $factory->make($options['file'], $this->args)->render();
        Cml::cmlStop();
        return;
    }