<?php
/*
* This file is part of Mustache.php.
*
* (c) 2010-2015 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A Mustache implementation in PHP.
*
* {@link http://defunkt.github.com/mustache}
*
* Mustache is a framework-agnostic logic-less templating language. It enforces separation of view
* logic from template files. In fact, it is not even possible to embed logic in the template.
*
* This is very, very rad.
*
* @author Justin Hileman {@link http://justinhileman.com}
*/
class Mustache_Engine
{
const VERSION = '2.9.0';
const SPEC_VERSION = '1.1.2';
const PRAGMA_FILTERS = 'FILTERS';
const PRAGMA_BLOCKS = 'BLOCKS';
const PRAGMA_ANCHORED_DOT = 'ANCHORED-DOT';
// Known pragmas
private static $knownPragmas = array(
self::PRAGMA_FILTERS => true,
self::PRAGMA_BLOCKS => true,
self::PRAGMA_ANCHORED_DOT => true,
);
// Template cache
private $templates = array();
// Environment
private $templateClassPrefix = '__Mustache_';
private $cache;
private $lambdaCache;
private $cacheLambdaTemplates = false;
private $loader;
private $partialsLoader;
private $helpers;
private $escape;
private $entityFlags = ENT_COMPAT;
private $charset = 'UTF-8';
private $logger;
private $strictCallables = false;
private $pragmas = array();
// Services
private $tokenizer;
private $parser;
private $compiler;
/**
* Mustache class constructor.
*
* Passing an $options array allows overriding certain Mustache options during instantiation:
*
* $options = array(
* // The class prefix for compiled templates. Defaults to '__Mustache_'.
* 'template_class_prefix' => '__MyTemplates_',
*
* // A Mustache cache instance or a cache directory string for compiled templates.
* // Mustache will not cache templates unless this is set.
* 'cache' => dirname(__FILE__).'/tmp/cache/mustache',
*
* // Override default permissions for cache files. Defaults to using the system-defined umask. It is
* // *strongly* recommended that you configure your umask properly rather than overriding permissions here.
* 'cache_file_mode' => 0666,
*
* // Optionally, enable caching for lambda section templates. This is generally not recommended, as lambda
* // sections are often too dynamic to benefit from caching.
* 'cache_lambda_templates' => true,
*
* // A Mustache template loader instance. Uses a StringLoader if not specified.
* 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'),
*
* // A Mustache loader instance for partials.
* 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials'),
*
* // An array of Mustache partials. Useful for quick-and-dirty string template loading, but not as
* // efficient or lazy as a Filesystem (or database) loader.
* 'partials' => array('foo' => file_get_contents(dirname(__FILE__).'/views/partials/foo.mustache')),
*
* // An array of 'helpers'. Helpers can be global variables or objects, closures (e.g. for higher order
* // sections), or any other valid Mustache context value. They will be prepended to the context stack,
* // so they will be available in any template loaded by this Mustache instance.
* 'helpers' => array('i18n' => function ($text) {
* // do something translatey here...
* }),
*
* // An 'escape' callback, responsible for escaping double-mustache variables.
* 'escape' => function ($value) {
* return htmlspecialchars($buffer, ENT_COMPAT, 'UTF-8');
* },
*
* // Type argument for `htmlspecialchars`. Defaults to ENT_COMPAT. You may prefer ENT_QUOTES.
* 'entity_flags' => ENT_QUOTES,
*
* // Character set for `htmlspecialchars`. Defaults to 'UTF-8'. Use 'UTF-8'.
* 'charset' => 'ISO-8859-1',
*
* // A Mustache Logger instance. No logging will occur unless this is set. Using a PSR-3 compatible
* // logging library -- such as Monolog -- is highly recommended. A simple stream logger implementation is
* // available as well:
* 'logger' => new Mustache_Logger_StreamLogger('php://stderr'),
*
* // Only treat Closure instances and invokable classes as callable. If true, values like
* // `array('ClassName', 'methodName')` and `array($classInstance, 'methodName')`, which are traditionally
* // "callable" in PHP, are not called to resolve variables for interpolation or section contexts. This
* // helps protect against arbitrary code execution when user input is passed directly into the template.
* // This currently defaults to false, but will default to true in v3.0.
* 'strict_callables' => true,
*
* // Enable pragmas across all templates, regardless of the presence of pragma tags in the individual
* // templates.
* 'pragmas' => [Mustache_Engine::PRAGMA_FILTERS],
* );
*
* @throws Mustache_Exception_InvalidArgumentException If `escape` option is not callable.
*
* @param array $options (default: array())
*/
public function __construct(array $options = array())
{
if (isset($options['template_class_prefix'])) {
$this->templateClassPrefix = $options['template_class_prefix'];
}
if (isset($options['cache'])) {
$cache = $options['cache'];
if (is_string($cache)) {
$mode = isset($options['cache_file_mode']) ? $options['cache_file_mode'] : null;
$cache = new Mustache_Cache_FilesystemCache($cache, $mode);
}
$this->setCache($cache);
}
if (isset($options['cache_lambda_templates'])) {
$this->cacheLambdaTemplates = (bool) $options['cache_lambda_templates'];
}
if (isset($options['loader'])) {
$this->setLoader($options['loader']);
}
if (isset($options['partials_loader'])) {
$this->setPartialsLoader($options['partials_loader']);
}
if (isset($options['partials'])) {
$this->setPartials($options['partials']);
}
if (isset($options['helpers'])) {
$this->setHelpers($options['helpers']);
}
if (isset($options['escape'])) {
if (!is_callable($options['escape'])) {
throw new Mustache_Exception_InvalidArgumentException('Mustache Constructor "escape" option must be callable');
}
$this->escape = $options['escape'];
}
if (isset($options['entity_flags'])) {
$this->entityFlags = $options['entity_flags'];
}
if (isset($options['charset'])) {
$this->charset = $options['charset'];
}
if (isset($options['logger'])) {
$this->setLogger($options['logger']);
}
if (isset($options['strict_callables'])) {
$this->strictCallables = $options['strict_callables'];
}
if (isset($options['pragmas'])) {
foreach ($options['pragmas'] as $pragma) {
if (!isset(self::$knownPragmas[$pragma])) {
throw new Mustache_Exception_InvalidArgumentException(sprintf('Unknown pragma: "%s".', $pragma));
}
$this->pragmas[$pragma] = true;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Ace - Responsive Admin Template v1.3.5 (1187个子文件)
changelog 8KB
ace.css 482KB
ace.min.css 385KB
ace-rtl.css 150KB
ace-part2.css 146KB
bootstrap.css 142KB
ace-rtl.min.css 122KB
ace-part2.min.css 115KB
bootstrap.min.css 114KB
ace-skins.css 99KB
ace-skins.min.css 82KB
font-awesome.css 32KB
bootstrap-datepicker3.css 28KB
font-awesome.min.css 27KB
bootstrap-datepicker3.min.css 26KB
fullcalendar.css 24KB
bootstrap-editable.css 21KB
jquery-ui.css 18KB
select2.css 17KB
bootstrap-editable.min.css 17KB
ui.jqgrid.css 16KB
jquery-ui.min.css 15KB
select2.min.css 14KB
chosen.css 13KB
ui.jqgrid.min.css 13KB
dropzone.css 12KB
ace-ie.css 12KB
fullcalendar.min.css 11KB
chosen.min.css 11KB
ace-ie.min.css 9KB
dropzone.min.css 9KB
bootstrap-datetimepicker.css 9KB
codemirror.css 8KB
bootstrap-datetimepicker.min.css 8KB
daterangepicker.css 7KB
daterangepicker.min.css 5KB
fullcalendar.print.css 5KB
ace.onpage-help.css 5KB
colorbox.css 4KB
jquery-ui.custom.css 4KB
bootstrap-timepicker.css 3KB
frontend.css 3KB
jquery-ui.custom.min.css 3KB
bootstrap-timepicker.min.css 3KB
colorbox.min.css 3KB
colorpicker.css 2KB
prettify.css 2KB
dreamweaver.css 2KB
bootstrap-duallistbox.css 2KB
colorpicker.min.css 2KB
jquery.gritter.css 2KB
fullcalendar.print.min.css 2KB
pastie.css 2KB
jquery.gritter.min.css 2KB
github.css 1KB
solarized-light.css 1KB
solarized-dark.css 1KB
sunburst.css 1KB
bootstrap-duallistbox.min.css 1KB
style.css 1KB
monokai.css 1KB
bootstrap-multiselect.css 1KB
bootstrap-multiselect.min.css 1KB
twilight.css 1KB
obsidian.css 1KB
blackboard.css 968B
paraiso-light.css 953B
paraiso-dark.css 952B
kimbie-light.css 950B
kimbie-dark.css 949B
espresso-libre.css 949B
tomorrow-night.css 924B
tricolore.css 795B
zenburnesque.css 759B
grid.css 757B
all-hallows-eve.css 629B
prettify.min.css 532B
ace-fonts.css 452B
foldgutter.css 435B
ace-fonts.min.css 326B
elements.css 305B
pace.css 289B
pace.min.css 222B
fullscreen.css 116B
domains2.csv 909B
states.csv 885B
states.csv 885B
states.csv 885B
states.csv 885B
friends.csv 549B
members.csv 370B
domains1.csv 226B
members.csv 184B
domains.csv 181B
fontawesome-webfont.eot 69KB
fontawesome-webfont.eot 69KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
loading.gif 8KB
loading.gif 8KB
共 1187 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
wangfansail
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 人工智能ai相关教学课程快
- Suno的冲击-AI音乐来了-学习备用.pdf
- KIMI大模型浏览器插件
- b61fa64a08a02de0e0d49d53bb84c444.amr
- 分布式系统中Java后端开发技术及其应用实践.pdf
- 5ffd9193f6aec31bbf16030a46680dc7.avi
- DA14531-蓝牙传感器连接传输数据固件
- 极限存在准则与两个重要极限
- logisim实验MIPS运算器(ALU)设计(内含4位先行进位74182、四位快速加法器、32位快速加法器)-Educoder_logisim里面连线,实现4位先行进位74182和4位快速加法器-C
- 高等数学第一章第二节数列的极限
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页