vr-shopxo-source/thinkphp/library/think/Template.php

1319 lines
47 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think;
use think\exception\TemplateNotFoundException;
/**
* ThinkPHP分离出来的模板引擎
* 支持XML标签和普通标签的模板解析
* 编译型模板引擎 支持动态缓存
*/
class Template
{
protected $app;
/**
* 模板变量
* @var array
*/
protected $data = [];
/**
* 模板配置参数
* @var array
*/
protected $config = [
'view_path' => '', // 模板路径
'view_base' => '',
'view_suffix' => 'html', // 默认模板文件后缀
'view_depr' => DIRECTORY_SEPARATOR,
'cache_suffix' => 'php', // 默认模板缓存后缀
'tpl_deny_func_list' => 'echo,exit', // 模板引擎禁用函数
'tpl_deny_php' => false, // 默认模板引擎是否禁用PHP原生代码
'tpl_begin' => '{', // 模板引擎普通标签开始标记
'tpl_end' => '}', // 模板引擎普通标签结束标记
'strip_space' => false, // 是否去除模板文件里面的html空格与换行
'tpl_cache' => true, // 是否开启模板编译缓存,设为false则每次都会重新编译
'compile_type' => 'file', // 模板编译类型
'cache_prefix' => '', // 模板缓存前缀标识,可以动态改变
'cache_time' => 0, // 模板缓存有效期 0 为永久,(以数字为值,单位:秒)
'layout_on' => false, // 布局模板开关
'layout_name' => 'layout', // 布局模板入口文件
'layout_item' => '{__CONTENT__}', // 布局模板的内容替换标识
'taglib_begin' => '{', // 标签库标签开始标记