<?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框架文档
共1145个文件
js:323个
less:165个
html:141个
5星 · 超过95%的资源 需积分: 30 514 下载量 22 浏览量
2018-03-13
15:00:17
上传
评论 12
收藏 6.81MB RAR 举报
温馨提示
ace 框架,包括详细的英文文档(都挺简单的英文,helloWorld级别) 简单的中文说明,可参考:http://www.cnblogs.com/LeeScofiled/p/6733625.html
资源推荐
资源详情
资源评论
收起资源包目录
ace框架文档 (1145个子文件)
changelog 7KB
ace.css 478KB
ace.min.css 382KB
ace-rtl.css 149KB
bootstrap.css 142KB
ace-part2.css 136KB
ace-rtl.min.css 122KB
bootstrap.min.css 115KB
ace-part2.min.css 108KB
ace-skins.css 99KB
ace-skins.min.css 82KB
bootstrap-datepicker3.css 32KB
font-awesome.css 32KB
bootstrap-datepicker3.min.css 30KB
font-awesome.min.css 26KB
fullcalendar.css 24KB
bootstrap-editable.css 21KB
select2.css 19KB
jquery-ui.css 18KB
bootstrap-editable.min.css 17KB
ui.jqgrid.css 16KB
select2.min.css 15KB
jquery-ui.min.css 15KB
chosen.css 13KB
ui.jqgrid.min.css 13KB
dropzone.css 12KB
fullcalendar.min.css 11KB
chosen.min.css 11KB
ace-ie.css 11KB
dropzone.min.css 9KB
bootstrap-datetimepicker.css 9KB
ace-ie.min.css 9KB
codemirror.css 8KB
bootstrap-datetimepicker.min.css 8KB
daterangepicker.css 6KB
fullcalendar.print.css 5KB
ace.onpage-help.css 5KB
daterangepicker.min.css 5KB
colorbox.css 4KB
jquery-ui.custom.css 4KB
bootstrap-timepicker.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
espresso-libre.css 949B
kimbie-dark.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
friends.csv 549B
members.csv 370B
domains1.csv 226B
members.csv 184B
domains.csv 181B
fontawesome-webfont.eot 67KB
fontawesome-webfont.eot 67KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
loading.gif 8KB
loading.gif 8KB
select2-spinner.gif 2KB
loading.gif 2KB
共 1145 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
冰冻开水
- 粉丝: 5
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页