mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-50150 Mustache: Update to 2.9.0 version of mustache.php
And enable the BLOCKS pragma (we need it for reusable templates).
This commit is contained in:
parent
841e689a1c
commit
85fa6a9305
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2014 Justin Hileman
|
||||
Copyright (c) 2010-2015 Justin Hileman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -3,9 +3,9 @@ Mustache.php
|
||||
|
||||
A [Mustache](http://mustache.github.com/) implementation in PHP.
|
||||
|
||||
[![Package version](http://img.shields.io/packagist/v/mustache/mustache.svg)](https://packagist.org/packages/mustache/mustache)
|
||||
[![Build status](http://img.shields.io/travis/bobthecow/mustache.php/dev.svg)](http://travis-ci.org/bobthecow/mustache.php)
|
||||
[![Monthly downloads](http://img.shields.io/packagist/dm/mustache/mustache.svg)](https://packagist.org/packages/mustache/mustache)
|
||||
[![Package version](http://img.shields.io/packagist/v/mustache/mustache.svg?style=flat-square)](https://packagist.org/packages/mustache/mustache)
|
||||
[![Build status](http://img.shields.io/travis/bobthecow/mustache.php/dev.svg?style=flat-square)](http://travis-ci.org/bobthecow/mustache.php)
|
||||
[![Monthly downloads](http://img.shields.io/packagist/dm/mustache/mustache.svg?style=flat-square)](https://packagist.org/packages/mustache/mustache)
|
||||
|
||||
|
||||
Usage
|
||||
@ -24,9 +24,9 @@ And a more in-depth example -- this is the canonical Mustache template:
|
||||
|
||||
```html+jinja
|
||||
Hello {{name}}
|
||||
You have just won ${{value}}!
|
||||
You have just won {{value}} dollars!
|
||||
{{#in_ca}}
|
||||
Well, ${{taxed_value}}, after taxes.
|
||||
Well, {{taxed_value}} dollars, after taxes.
|
||||
{{/in_ca}}
|
||||
```
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "mustache/mustache",
|
||||
"description": "A Mustache implementation in PHP.",
|
||||
"keywords": ["templating", "mustache"],
|
||||
"homepage": "https://github.com/bobthecow/mustache.php",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Justin Hileman",
|
||||
"email": "justin@justinhileman.info",
|
||||
"homepage": "http://justinhileman.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Mustache": "src/" }
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
Description of Mustache library import into moodle.
|
||||
|
||||
Download from https://github.com/bobthecow/mustache.php
|
||||
Clone from https://github.com/moodle/custom-mustache.php
|
||||
|
||||
Rebase onto latest tag from https://github.com/bobthecow/mustache.php
|
||||
|
||||
Delete folder "test"
|
||||
|
||||
@ -9,3 +11,9 @@ Delete phpunit.xml.dist
|
||||
Delete hidden files ".*"
|
||||
|
||||
Delete folder "bin"
|
||||
|
||||
Delete folder "vendor"
|
||||
|
||||
Delete composer.json
|
||||
|
||||
Copy into this folder, and update this readme to cover any changes.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -24,7 +24,7 @@ class Mustache_Autoloader
|
||||
public function __construct($baseDir = null)
|
||||
{
|
||||
if ($baseDir === null) {
|
||||
$baseDir = dirname(__FILE__).'/..';
|
||||
$baseDir = dirname(__FILE__) . '/..';
|
||||
}
|
||||
|
||||
// realpath doesn't always work, for example, with stream URIs
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -22,7 +22,7 @@ interface Mustache_Cache
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return boolean indicates successfully class load
|
||||
* @return bool indicates successfully class load
|
||||
*/
|
||||
public function load($key);
|
||||
|
||||
@ -31,8 +31,6 @@ interface Mustache_Cache
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cache($key, $value);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -47,9 +47,9 @@ abstract class Mustache_Cache_AbstractCache implements Mustache_Cache
|
||||
/**
|
||||
* Add a log record if logging is enabled.
|
||||
*
|
||||
* @param integer $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @param int $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
*/
|
||||
protected function log($level, $message, array $context = array())
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -41,7 +41,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function load($key)
|
||||
{
|
||||
@ -56,12 +56,10 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache and load the compiled class
|
||||
* Cache and load the compiled class.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cache($key, $value)
|
||||
{
|
||||
@ -91,7 +89,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
|
||||
}
|
||||
|
||||
/**
|
||||
* Create cache directory
|
||||
* Create cache directory.
|
||||
*
|
||||
* @throws Mustache_Exception_RuntimeException If unable to create directory
|
||||
*
|
||||
@ -119,14 +117,12 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
|
||||
}
|
||||
|
||||
/**
|
||||
* Write cache file
|
||||
* Write cache file.
|
||||
*
|
||||
* @throws Mustache_Exception_RuntimeException If unable to write file
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function writeFile($fileName, $value)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -22,7 +22,7 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function load($key)
|
||||
{
|
||||
@ -34,8 +34,6 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cache($key, $value)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -16,10 +16,10 @@
|
||||
*/
|
||||
class Mustache_Compiler
|
||||
{
|
||||
|
||||
private $pragmas;
|
||||
private $defaultPragmas = array();
|
||||
private $sections;
|
||||
private $blocks;
|
||||
private $source;
|
||||
private $indentNextLine;
|
||||
private $customEscape;
|
||||
@ -44,6 +44,7 @@ class Mustache_Compiler
|
||||
{
|
||||
$this->pragmas = $this->defaultPragmas;
|
||||
$this->sections = array();
|
||||
$this->blocks = array();
|
||||
$this->source = $source;
|
||||
$this->indentNextLine = true;
|
||||
$this->customEscape = $customEscape;
|
||||
@ -196,6 +197,7 @@ class Mustache_Compiler
|
||||
return $buffer;
|
||||
}
|
||||
%s
|
||||
%s
|
||||
}';
|
||||
|
||||
const KLASS_NO_LAMBDAS = '<?php
|
||||
@ -226,19 +228,19 @@ class Mustache_Compiler
|
||||
{
|
||||
$code = $this->walk($tree);
|
||||
$sections = implode("\n", $this->sections);
|
||||
$klass = empty($this->sections) ? self::KLASS_NO_LAMBDAS : self::KLASS;
|
||||
$blocks = implode("\n", $this->blocks);
|
||||
$klass = empty($this->sections) && empty($this->blocks) ? self::KLASS_NO_LAMBDAS : self::KLASS;
|
||||
|
||||
$callable = $this->strictCallables ? $this->prepare(self::STRICT_CALLABLE) : '';
|
||||
|
||||
return sprintf($this->prepare($klass, 0, false, true), $name, $callable, $code, $sections);
|
||||
return sprintf($this->prepare($klass, 0, false, true), $name, $callable, $code, $sections, $blocks);
|
||||
}
|
||||
|
||||
const BLOCK_VAR = '
|
||||
$value = $this->resolveValue($context->findInBlock(%s), $context, $indent);
|
||||
if ($value && !is_array($value) && !is_object($value)) {
|
||||
$buffer .= $value;
|
||||
} else {
|
||||
%s
|
||||
$blockFunction = $context->findInBlock(%s);
|
||||
if (is_callable($blockFunction)) {
|
||||
$buffer .= call_user_func($blockFunction, $context);
|
||||
} else {%s
|
||||
}
|
||||
';
|
||||
|
||||
@ -259,14 +261,10 @@ class Mustache_Compiler
|
||||
{
|
||||
$id = var_export($id, true);
|
||||
|
||||
return sprintf($this->prepare(self::BLOCK_VAR, $level), $id, $this->walk($nodes, 2));
|
||||
return sprintf($this->prepare(self::BLOCK_VAR, $level), $id, $this->walk($nodes, $level));
|
||||
}
|
||||
|
||||
const BLOCK_ARG = '
|
||||
// %s block_arg
|
||||
$value = $this->section%s($context, $indent, true);
|
||||
$newContext[%s] = %s$value;
|
||||
';
|
||||
const BLOCK_ARG = '$newContext[%s] = array($this, \'block%s\');';
|
||||
|
||||
/**
|
||||
* Generate Mustache Template inheritance block argument PHP source.
|
||||
@ -283,10 +281,39 @@ class Mustache_Compiler
|
||||
*/
|
||||
private function blockArg($nodes, $id, $start, $end, $otag, $ctag, $level)
|
||||
{
|
||||
$key = $this->section($nodes, $id, array(), $start, $end, $otag, $ctag, $level, true);
|
||||
$id = var_export($id, true);
|
||||
$key = $this->block($nodes);
|
||||
$keystr = var_export($key, true);
|
||||
$id = var_export($id, true);
|
||||
|
||||
return sprintf($this->prepare(self::BLOCK_ARG, $level), $id, $key, $id, $this->flushIndent());
|
||||
return sprintf($this->prepare(self::BLOCK_ARG, 1), $id, $key);
|
||||
}
|
||||
|
||||
const BLOCK_FUNCTION = '
|
||||
public function block%s($context)
|
||||
{
|
||||
$indent = $buffer = \'\';%s
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
';
|
||||
|
||||
/**
|
||||
* Generate Mustache Template inheritance block function PHP source.
|
||||
*
|
||||
* @param array $nodes Array of child tokens
|
||||
*
|
||||
* @return string key of new block function
|
||||
*/
|
||||
private function block($nodes)
|
||||
{
|
||||
$code = $this->walk($nodes, 0);
|
||||
$key = ucfirst(md5($code));
|
||||
|
||||
if (!isset($this->blocks[$key])) {
|
||||
$this->blocks[$key] = sprintf($this->prepare(self::BLOCK_FUNCTION, 0), $key, $code);
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
const SECTION_CALL = '
|
||||
@ -319,7 +346,8 @@ class Mustache_Compiler
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}';
|
||||
}
|
||||
';
|
||||
|
||||
/**
|
||||
* Generate Mustache Template section PHP source.
|
||||
@ -342,12 +370,12 @@ class Mustache_Compiler
|
||||
$callable = $this->getCallable();
|
||||
|
||||
if ($otag !== '{{' || $ctag !== '}}') {
|
||||
$delims = ', '.var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true);
|
||||
$delims = ', ' . var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true);
|
||||
} else {
|
||||
$delims = '';
|
||||
}
|
||||
|
||||
$key = ucfirst(md5($delims."\n".$source));
|
||||
$key = ucfirst(md5($delims . "\n" . $source));
|
||||
|
||||
if (!isset($this->sections[$key])) {
|
||||
$this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $delims, $this->walk($nodes, 2));
|
||||
@ -369,7 +397,8 @@ class Mustache_Compiler
|
||||
$value = $context->%s(%s);%s
|
||||
if (empty($value)) {
|
||||
%s
|
||||
}';
|
||||
}
|
||||
';
|
||||
|
||||
/**
|
||||
* Generate Mustache Template inverted section PHP source.
|
||||
@ -458,7 +487,7 @@ class Mustache_Compiler
|
||||
*
|
||||
* @param array $node
|
||||
*
|
||||
* @return boolean True if $node is a block arg token.
|
||||
* @return bool True if $node is a block arg token.
|
||||
*/
|
||||
private static function onlyBlockArgs(array $node)
|
||||
{
|
||||
@ -475,7 +504,7 @@ class Mustache_Compiler
|
||||
*
|
||||
* @param string $id Variable name
|
||||
* @param string[] $filters Array of filters
|
||||
* @param boolean $escape Escape the variable value for output?
|
||||
* @param bool $escape Escape the variable value for output?
|
||||
* @param int $level
|
||||
*
|
||||
* @return string Generated variable interpolation PHP source
|
||||
@ -544,16 +573,16 @@ class Mustache_Compiler
|
||||
/**
|
||||
* Prepare PHP source code snippet for output.
|
||||
*
|
||||
* @param string $text
|
||||
* @param int $bonus Additional indent level (default: 0)
|
||||
* @param boolean $prependNewline Prepend a newline to the snippet? (default: true)
|
||||
* @param boolean $appendNewline Append a newline to the snippet? (default: false)
|
||||
* @param string $text
|
||||
* @param int $bonus Additional indent level (default: 0)
|
||||
* @param bool $prependNewline Prepend a newline to the snippet? (default: true)
|
||||
* @param bool $appendNewline Append a newline to the snippet? (default: false)
|
||||
*
|
||||
* @return string PHP source code snippet
|
||||
*/
|
||||
private function prepare($text, $bonus = 0, $prependNewline = true, $appendNewline = false)
|
||||
{
|
||||
$text = ($prependNewline ? "\n" : '').trim($text);
|
||||
$text = ($prependNewline ? "\n" : '') . trim($text);
|
||||
if ($prependNewline) {
|
||||
$bonus++;
|
||||
}
|
||||
@ -561,7 +590,7 @@ class Mustache_Compiler
|
||||
$text .= "\n";
|
||||
}
|
||||
|
||||
return preg_replace("/\n( {8})?/", "\n".str_repeat(" ", $bonus * 4), $text);
|
||||
return preg_replace("/\n( {8})?/", "\n" . str_repeat(' ', $bonus * 4), $text);
|
||||
}
|
||||
|
||||
const DEFAULT_ESCAPE = 'htmlspecialchars(%s, %s, %s)';
|
||||
@ -602,6 +631,12 @@ class Mustache_Compiler
|
||||
return 'last';
|
||||
}
|
||||
|
||||
if (isset($this->pragmas[Mustache_Engine::PRAGMA_ANCHORED_DOT]) && $this->pragmas[Mustache_Engine::PRAGMA_ANCHORED_DOT]) {
|
||||
if (substr($id, 0, 1) === '.') {
|
||||
return 'findAnchoredDot';
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($id, '.') === false) {
|
||||
return 'find';
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -141,6 +141,42 @@ class Mustache_Context
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an 'anchored dot notation' variable in the Context stack.
|
||||
*
|
||||
* This is the same as findDot(), except it looks in the top of the context
|
||||
* stack for the first value, rather than searching the whole context stack
|
||||
* and starting from there.
|
||||
*
|
||||
* @see Mustache_Context::findDot
|
||||
*
|
||||
* @throws Mustache_Exception_InvalidArgumentException if given an invalid anchored dot $id.
|
||||
*
|
||||
* @param string $id Dotted variable selector
|
||||
*
|
||||
* @return mixed Variable value, or '' if not found
|
||||
*/
|
||||
public function findAnchoredDot($id)
|
||||
{
|
||||
$chunks = explode('.', $id);
|
||||
$first = array_shift($chunks);
|
||||
if ($first !== '') {
|
||||
throw new Mustache_Exception_InvalidArgumentException(sprintf('Unexpected id for findAnchoredDot: %s', $id));
|
||||
}
|
||||
|
||||
$value = $this->last();
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
if ($value === '') {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$value = $this->findVariableInStack($chunk, array($value));
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an argument in the block context stack.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -23,16 +23,18 @@
|
||||
*/
|
||||
class Mustache_Engine
|
||||
{
|
||||
const VERSION = '2.7.0';
|
||||
const VERSION = '2.9.0';
|
||||
const SPEC_VERSION = '1.1.2';
|
||||
|
||||
const PRAGMA_FILTERS = 'FILTERS';
|
||||
const PRAGMA_BLOCKS = 'BLOCKS';
|
||||
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_FILTERS => true,
|
||||
self::PRAGMA_BLOCKS => true,
|
||||
self::PRAGMA_ANCHORED_DOT => true,
|
||||
);
|
||||
|
||||
// Template cache
|
||||
@ -174,7 +176,7 @@ class Mustache_Engine
|
||||
}
|
||||
|
||||
if (isset($options['entity_flags'])) {
|
||||
$this->entityFlags = $options['entity_flags'];
|
||||
$this->entityFlags = $options['entity_flags'];
|
||||
}
|
||||
|
||||
if (isset($options['charset'])) {
|
||||
@ -405,7 +407,7 @@ class Mustache_Engine
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return boolean True if the helper is present
|
||||
* @return bool True if the helper is present
|
||||
*/
|
||||
public function hasHelper($name)
|
||||
{
|
||||
@ -772,9 +774,9 @@ class Mustache_Engine
|
||||
/**
|
||||
* Add a log record if logging is enabled.
|
||||
*
|
||||
* @param integer $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @param int $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
*/
|
||||
private function log($level, $message, array $context = array())
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -103,7 +103,7 @@ class Mustache_HelperCollection
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return boolean True if helper is present
|
||||
* @return bool True if helper is present
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
@ -115,7 +115,7 @@ class Mustache_HelperCollection
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return boolean True if helper is present
|
||||
* @return bool True if helper is present
|
||||
*/
|
||||
public function has($name)
|
||||
{
|
||||
@ -163,7 +163,7 @@ class Mustache_HelperCollection
|
||||
/**
|
||||
* Check whether the helper collection is empty.
|
||||
*
|
||||
* @return boolean True if the collection is empty
|
||||
* @return bool True if the collection is empty
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -18,7 +18,7 @@ class Mustache_Loader_CascadingLoader implements Mustache_Loader
|
||||
private $loaders;
|
||||
|
||||
/**
|
||||
* Construct a CascadingLoader with an array of loaders:
|
||||
* Construct a CascadingLoader with an array of loaders.
|
||||
*
|
||||
* $loader = new Mustache_Loader_CascadingLoader(array(
|
||||
* new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__),
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -46,7 +46,6 @@
|
||||
*
|
||||
* @@ hello
|
||||
* Hello, {{ name }}!
|
||||
*
|
||||
*/
|
||||
class Mustache_Loader_InlineLoader implements Mustache_Loader
|
||||
{
|
||||
@ -56,6 +55,7 @@ class Mustache_Loader_InlineLoader implements Mustache_Loader
|
||||
|
||||
/**
|
||||
* The InlineLoader requires a filename and offset to process templates.
|
||||
*
|
||||
* The magic constants `__FILE__` and `__COMPILER_HALT_OFFSET__` are usually
|
||||
* perfectly suited to the job:
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -18,8 +18,6 @@ interface Mustache_Loader_MutableLoader
|
||||
* Set an associative array of Template sources for this loader.
|
||||
*
|
||||
* @param array $templates
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTemplates(array $templates);
|
||||
|
||||
@ -28,8 +26,6 @@ interface Mustache_Loader_MutableLoader
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $template Mustache Template source
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTemplate($name, $template);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,14 +3,14 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Describes a Mustache logger instance
|
||||
* Describes a Mustache logger instance.
|
||||
*
|
||||
* This is identical to the Psr\Log\LoggerInterface.
|
||||
*
|
||||
@ -29,7 +29,7 @@
|
||||
interface Mustache_Logger
|
||||
{
|
||||
/**
|
||||
* Psr\Log compatible log levels
|
||||
* Psr\Log compatible log levels.
|
||||
*/
|
||||
const EMERGENCY = 'emergency';
|
||||
const ALERT = 'alert';
|
||||
@ -45,8 +45,6 @@ interface Mustache_Logger
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function emergency($message, array $context = array());
|
||||
|
||||
@ -58,8 +56,6 @@ interface Mustache_Logger
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function alert($message, array $context = array());
|
||||
|
||||
@ -70,8 +66,6 @@ interface Mustache_Logger
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function critical($message, array $context = array());
|
||||
|
||||
@ -81,8 +75,6 @@ interface Mustache_Logger
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function error($message, array $context = array());
|
||||
|
||||
@ -94,8 +86,6 @@ interface Mustache_Logger
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function warning($message, array $context = array());
|
||||
|
||||
@ -104,8 +94,6 @@ interface Mustache_Logger
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function notice($message, array $context = array());
|
||||
|
||||
@ -116,8 +104,6 @@ interface Mustache_Logger
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function info($message, array $context = array());
|
||||
|
||||
@ -126,8 +112,6 @@ interface Mustache_Logger
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function debug($message, array $context = array());
|
||||
|
||||
@ -137,8 +121,6 @@ interface Mustache_Logger
|
||||
* @param mixed $level
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function log($level, $message, array $context = array());
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -39,7 +39,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
|
||||
* @throws InvalidArgumentException if the logging level is unknown.
|
||||
*
|
||||
* @param resource|string $stream Resource instance or URL
|
||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||
* @param int $level The minimum logging level at which this handler will be triggered
|
||||
*/
|
||||
public function __construct($stream, $level = Mustache_Logger::ERROR)
|
||||
{
|
||||
@ -67,7 +67,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
|
||||
*
|
||||
* @throws Mustache_Exception_InvalidArgumentException if the logging level is unknown.
|
||||
*
|
||||
* @param integer $level The minimum logging level which will be written
|
||||
* @param int $level The minimum logging level which will be written
|
||||
*/
|
||||
public function setLevel($level)
|
||||
{
|
||||
@ -81,7 +81,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
|
||||
/**
|
||||
* Get the current minimum logging level.
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getLevel()
|
||||
{
|
||||
@ -114,9 +114,9 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
|
||||
* @throws Mustache_Exception_LogicException If neither a stream resource nor url is present.
|
||||
* @throws Mustache_Exception_RuntimeException If the stream url cannot be opened.
|
||||
*
|
||||
* @param integer $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @param int $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
*/
|
||||
protected function writeLog($level, $message, array $context = array())
|
||||
{
|
||||
@ -141,7 +141,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
|
||||
*
|
||||
* @throws InvalidArgumentException if the logging level is unknown.
|
||||
*
|
||||
* @param integer $level
|
||||
* @param int $level
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -153,9 +153,9 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
|
||||
/**
|
||||
* Format a log line for output.
|
||||
*
|
||||
* @param integer $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @param int $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -254,7 +254,7 @@ class Mustache_Parser
|
||||
*
|
||||
* @param array $token
|
||||
*
|
||||
* @return boolean True if token is a whitespace token
|
||||
* @return bool True if token is a whitespace token
|
||||
*/
|
||||
private function tokenIsWhitespace(array $token)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -22,7 +22,7 @@ abstract class Mustache_Template
|
||||
protected $mustache;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $strictCallables = false;
|
||||
|
||||
@ -37,7 +37,7 @@ abstract class Mustache_Template
|
||||
}
|
||||
|
||||
/**
|
||||
* Mustache Template instances can be treated as a function and rendered by simply calling them:
|
||||
* Mustache Template instances can be treated as a function and rendered by simply calling them.
|
||||
*
|
||||
* $m = new Mustache_Engine;
|
||||
* $tpl = $m->loadTemplate('Hello, {{ name }}!');
|
||||
@ -109,7 +109,7 @@ abstract class Mustache_Template
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return boolean True if the value is 'iterable'
|
||||
* @return bool True if the value is 'iterable'
|
||||
*/
|
||||
protected function isIterable($value)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
* (c) 2010-2015 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@ -53,13 +53,6 @@ class Mustache_Tokenizer
|
||||
self::T_BLOCK_VAR => true,
|
||||
);
|
||||
|
||||
// Interpolated tags
|
||||
private static $interpolatedTags = array(
|
||||
self::T_ESCAPED => true,
|
||||
self::T_UNESCAPED => true,
|
||||
self::T_UNESCAPED_2 => true,
|
||||
);
|
||||
|
||||
// Token properties
|
||||
const TYPE = 'type';
|
||||
const NAME = 'name';
|
||||
@ -75,7 +68,6 @@ class Mustache_Tokenizer
|
||||
|
||||
private $state;
|
||||
private $tagType;
|
||||
private $tag;
|
||||
private $buffer;
|
||||
private $tokens;
|
||||
private $seenTag;
|
||||
@ -163,7 +155,7 @@ class Mustache_Tokenizer
|
||||
self::OTAG => $this->otag,
|
||||
self::CTAG => $this->ctag,
|
||||
self::LINE => $this->line,
|
||||
self::INDEX => ($this->tagType === self::T_END_SECTION) ? $this->seenTag - $this->otagLen : $i + $this->ctagLen
|
||||
self::INDEX => ($this->tagType === self::T_END_SECTION) ? $this->seenTag - $this->otagLen : $i + $this->ctagLen,
|
||||
);
|
||||
|
||||
if ($this->tagType === self::T_UNESCAPED) {
|
||||
@ -224,7 +216,6 @@ class Mustache_Tokenizer
|
||||
{
|
||||
$this->state = self::IN_TEXT;
|
||||
$this->tagType = null;
|
||||
$this->tag = null;
|
||||
$this->buffer = '';
|
||||
$this->tokens = array();
|
||||
$this->seenTag = false;
|
||||
@ -244,7 +235,7 @@ class Mustache_Tokenizer
|
||||
$this->tokens[] = array(
|
||||
self::TYPE => self::T_TEXT,
|
||||
self::LINE => $this->line,
|
||||
self::VALUE => $this->buffer
|
||||
self::VALUE => $this->buffer,
|
||||
);
|
||||
$this->buffer = '';
|
||||
}
|
||||
@ -261,7 +252,7 @@ class Mustache_Tokenizer
|
||||
private function changeDelimiters($text, $index)
|
||||
{
|
||||
$startIndex = strpos($text, '=', $index) + 1;
|
||||
$close = '='.$this->ctag;
|
||||
$close = '=' . $this->ctag;
|
||||
$closeIndex = strpos($text, $close, $index);
|
||||
|
||||
$this->setDelimiters(trim(substr($text, $startIndex, $closeIndex - $startIndex)));
|
||||
@ -322,7 +313,7 @@ class Mustache_Tokenizer
|
||||
* @param string $text Mustache template source
|
||||
* @param int $index Current tokenizer index
|
||||
*
|
||||
* @return boolean True if this is a closing section tag
|
||||
* @return bool True if this is a closing section tag
|
||||
*/
|
||||
private function tagChange($tag, $tagLen, $text, $index)
|
||||
{
|
||||
|
@ -106,7 +106,8 @@ class renderer_base {
|
||||
'cache' => $cachedir,
|
||||
'escape' => 's',
|
||||
'loader' => $loader,
|
||||
'helpers' => $helpers));
|
||||
'helpers' => $helpers,
|
||||
'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS]));
|
||||
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@
|
||||
<location>mustache</location>
|
||||
<name>Mustache</name>
|
||||
<license>MIT</license>
|
||||
<version>2.7.0</version>
|
||||
<version>2.9.0</version>
|
||||
</library>
|
||||
<library>
|
||||
<location>amd/src/mustache.js</location>
|
||||
|
Loading…
x
Reference in New Issue
Block a user