And enable the BLOCKS pragma (we need it for reusable templates).
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
A [Mustache](http://mustache.github.com/) implementation in PHP.
-[](https://packagist.org/packages/mustache/mustache)
-[](http://travis-ci.org/bobthecow/mustache.php)
-[](https://packagist.org/packages/mustache/mustache)
+[](https://packagist.org/packages/mustache/mustache)
+[](http://travis-ci.org/bobthecow/mustache.php)
+[](https://packagist.org/packages/mustache/mustache)
Usage
```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}}
```
+++ /dev/null
-{
- "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/" }
- }
-}
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"
Delete hidden files ".*"
Delete folder "bin"
+
+Delete folder "vendor"
+
+Delete composer.json
+
+Copy into this folder, and update this readme to cover any changes.
/*
* 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.
public function __construct($baseDir = null)
{
if ($baseDir === null) {
- $baseDir = dirname(__FILE__).'/..';
+ $baseDir = dirname(__FILE__) . '/..';
}
// realpath doesn't always work, for example, with stream URIs
/*
* 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.
*
* @param string $key
*
- * @return boolean indicates successfully class load
+ * @return bool indicates successfully class load
*/
public function load($key);
*
* @param string $key
* @param string $value
- *
- * @return void
*/
public function cache($key, $value);
}
/*
* 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.
/**
* 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())
{
/*
* 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.
*
* @param string $key
*
- * @return boolean
+ * @return bool
*/
public function load($key)
{
}
/**
- * 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)
{
}
/**
- * Create cache directory
+ * Create cache directory.
*
* @throws Mustache_Exception_RuntimeException If unable to create directory
*
}
/**
- * 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)
{
/*
* 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.
*
* @param string $key
*
- * @return boolean
+ * @return bool
*/
public function load($key)
{
*
* @param string $key
* @param string $value
- *
- * @return void
*/
public function cache($key, $value)
{
/*
* 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.
*/
class Mustache_Compiler
{
-
private $pragmas;
private $defaultPragmas = array();
private $sections;
+ private $blocks;
private $source;
private $indentNextLine;
private $customEscape;
{
$this->pragmas = $this->defaultPragmas;
$this->sections = array();
+ $this->blocks = array();
$this->source = $source;
$this->indentNextLine = true;
$this->customEscape = $customEscape;
return $buffer;
}
%s
+ %s
}';
const KLASS_NO_LAMBDAS = '<?php
{
$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
}
';
{
$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.
*/
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, 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));
- return sprintf($this->prepare(self::BLOCK_ARG, $level), $id, $key, $id, $this->flushIndent());
+ if (!isset($this->blocks[$key])) {
+ $this->blocks[$key] = sprintf($this->prepare(self::BLOCK_FUNCTION, 0), $key, $code);
+ }
+
+ return $key;
}
const SECTION_CALL = '
}
return $buffer;
- }';
+ }
+ ';
/**
* Generate Mustache Template section PHP source.
$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));
$value = $context->%s(%s);%s
if (empty($value)) {
%s
- }';
+ }
+ ';
/**
* Generate Mustache Template inverted section PHP source.
*
* @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)
{
*
* @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
/**
* 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++;
}
$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)';
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';
}
/*
* 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.
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.
*
/*
* 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.
*/
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
}
if (isset($options['entity_flags'])) {
- $this->entityFlags = $options['entity_flags'];
+ $this->entityFlags = $options['entity_flags'];
}
if (isset($options['charset'])) {
*
* @param string $name
*
- * @return boolean True if the helper is present
+ * @return bool True if the helper is present
*/
public function hasHelper($name)
{
/**
* 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())
{
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
*
* @param string $name
*
- * @return boolean True if helper is present
+ * @return bool True if helper is present
*/
public function __isset($name)
{
*
* @param string $name
*
- * @return boolean True if helper is present
+ * @return bool True if helper is present
*/
public function has($name)
{
/**
* 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()
{
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
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__),
/*
* 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.
/*
* 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.
*
* @@ hello
* Hello, {{ name }}!
- *
*/
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:
*
/*
* 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.
* Set an associative array of Template sources for this loader.
*
* @param array $templates
- *
- * @return void
*/
public function setTemplates(array $templates);
*
* @param string $name
* @param string $template Mustache Template source
- *
- * @return void
*/
public function setTemplate($name, $template);
}
/*
* 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.
/*
* 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.
*
interface Mustache_Logger
{
/**
- * Psr\Log compatible log levels
+ * Psr\Log compatible log levels.
*/
const EMERGENCY = 'emergency';
const ALERT = 'alert';
*
* @param string $message
* @param array $context
- *
- * @return null
*/
public function emergency($message, array $context = array());
*
* @param string $message
* @param array $context
- *
- * @return null
*/
public function alert($message, array $context = array());
*
* @param string $message
* @param array $context
- *
- * @return null
*/
public function critical($message, array $context = array());
*
* @param string $message
* @param array $context
- *
- * @return null
*/
public function error($message, array $context = array());
*
* @param string $message
* @param array $context
- *
- * @return null
*/
public function warning($message, array $context = array());
*
* @param string $message
* @param array $context
- *
- * @return null
*/
public function notice($message, array $context = array());
*
* @param string $message
* @param array $context
- *
- * @return null
*/
public function info($message, array $context = array());
*
* @param string $message
* @param array $context
- *
- * @return null
*/
public function debug($message, array $context = array());
* @param mixed $level
* @param string $message
* @param array $context
- *
- * @return null
*/
public function log($level, $message, array $context = array());
}
/*
* 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.
/*
* 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.
* @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)
{
*
* @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)
{
/**
* Get the current minimum logging level.
*
- * @return integer
+ * @return int
*/
public function getLevel()
{
* @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())
{
*
* @throws InvalidArgumentException if the logging level is unknown.
*
- * @param integer $level
+ * @param int $level
*
* @return string
*/
/**
* 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
*/
/*
* 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.
*
* @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)
{
/*
* 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.
protected $mustache;
/**
- * @var boolean
+ * @var bool
*/
protected $strictCallables = false;
}
/**
- * 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 }}!');
*
* @param mixed $value
*
- * @return boolean True if the value is 'iterable'
+ * @return bool True if the value is 'iterable'
*/
protected function isIterable($value)
{
/*
* 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.
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';
private $state;
private $tagType;
- private $tag;
private $buffer;
private $tokens;
private $seenTag;
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) {
{
$this->state = self::IN_TEXT;
$this->tagType = null;
- $this->tag = null;
$this->buffer = '';
$this->tokens = array();
$this->seenTag = false;
$this->tokens[] = array(
self::TYPE => self::T_TEXT,
self::LINE => $this->line,
- self::VALUE => $this->buffer
+ self::VALUE => $this->buffer,
);
$this->buffer = '';
}
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)));
* @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)
{
'cache' => $cachedir,
'escape' => 's',
'loader' => $loader,
- 'helpers' => $helpers));
+ 'helpers' => $helpers,
+ 'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS]));
}
<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>