mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-75388 lib: Update mustache to 2.14.1
MDL-67114 and MDL-73586 local changes removed as they are now available upstream.
This commit is contained in:
parent
a50c80b52a
commit
b014bb9985
@ -17,9 +17,3 @@ Local changes:
|
||||
Note: All this changes need to be reviewed on every upgrade and, if they have
|
||||
been already applied upstream for the release being used, can be removed
|
||||
from the list. If still not available upstream, they will need to be re-applied.
|
||||
|
||||
- MDL-67114: PHP 7.4 compatibility. Array operations on scalar value.
|
||||
This corresponds to upstream https://github.com/bobthecow/mustache.php/pull/352
|
||||
- MDL-73586: PHP 8.0 compatibility. Removed 'mbstring.func_overload' init setting.
|
||||
This corresponds to upstream commit https://github.com/bobthecow/mustache.php/commit/e7165a33b282ab4d20b3863825caadb46313d62b
|
||||
that is availbale for the library versions 2.14.1 and up
|
||||
|
@ -33,4 +33,11 @@ interface Mustache_Cache
|
||||
* @param string $value
|
||||
*/
|
||||
public function cache($key, $value);
|
||||
|
||||
/**
|
||||
* Set a logger instance.
|
||||
*
|
||||
* @param Mustache_Logger|Psr\Log\LoggerInterface $logger
|
||||
*/
|
||||
public function setLogger($logger = null);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ abstract class Mustache_Cache_AbstractCache implements Mustache_Cache
|
||||
/**
|
||||
* Add a log record if logging is enabled.
|
||||
*
|
||||
* @param int $level The logging level
|
||||
* @param string $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
*/
|
||||
|
@ -286,7 +286,6 @@ class Mustache_Compiler
|
||||
private function blockArg($nodes, $id, $start, $end, $otag, $ctag, $level)
|
||||
{
|
||||
$key = $this->block($nodes);
|
||||
$keystr = var_export($key, true);
|
||||
$id = var_export($id, true);
|
||||
|
||||
return sprintf($this->prepare(self::BLOCK_ARG, $level), $id, $key);
|
||||
@ -321,7 +320,6 @@ class Mustache_Compiler
|
||||
}
|
||||
|
||||
const SECTION_CALL = '
|
||||
// %s section
|
||||
$value = $context->%s(%s);%s
|
||||
$buffer .= $this->section%s($context, $indent, $value);
|
||||
';
|
||||
@ -333,12 +331,12 @@ class Mustache_Compiler
|
||||
|
||||
if (%s) {
|
||||
$source = %s;
|
||||
$result = call_user_func($value, $source, %s);
|
||||
$result = (string) call_user_func($value, $source, %s);
|
||||
if (strpos($result, \'{{\') === false) {
|
||||
$buffer .= $result;
|
||||
} else {
|
||||
$buffer .= $this->mustache
|
||||
->loadLambda((string) $result%s)
|
||||
->loadLambda($result%s)
|
||||
->renderInternal($context);
|
||||
}
|
||||
} elseif (!empty($value)) {
|
||||
@ -392,11 +390,10 @@ class Mustache_Compiler
|
||||
$id = var_export($id, true);
|
||||
$filters = $this->getFilters($filters, $level);
|
||||
|
||||
return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $method, $id, $filters, $key);
|
||||
return sprintf($this->prepare(self::SECTION_CALL, $level), $method, $id, $filters, $key);
|
||||
}
|
||||
|
||||
const INVERTED_SECTION = '
|
||||
// %s inverted section
|
||||
$value = $context->%s(%s);%s
|
||||
if (empty($value)) {
|
||||
%s
|
||||
@ -419,7 +416,7 @@ class Mustache_Compiler
|
||||
$id = var_export($id, true);
|
||||
$filters = $this->getFilters($filters, $level);
|
||||
|
||||
return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $filters, $this->walk($nodes, $level));
|
||||
return sprintf($this->prepare(self::INVERTED_SECTION, $level), $method, $id, $filters, $this->walk($nodes, $level));
|
||||
}
|
||||
|
||||
const PARTIAL_INDENT = ', $indent . %s';
|
||||
@ -507,7 +504,7 @@ class Mustache_Compiler
|
||||
|
||||
const VARIABLE = '
|
||||
$value = $this->resolveValue($context->%s(%s), $context);%s
|
||||
$buffer .= %s%s;
|
||||
$buffer .= %s($value === null ? \'\' : %s);
|
||||
';
|
||||
|
||||
/**
|
||||
|
@ -23,8 +23,8 @@
|
||||
*/
|
||||
class Mustache_Engine
|
||||
{
|
||||
const VERSION = '2.13.0';
|
||||
const SPEC_VERSION = '1.1.2';
|
||||
const VERSION = '2.14.0';
|
||||
const SPEC_VERSION = '1.2.2';
|
||||
|
||||
const PRAGMA_FILTERS = 'FILTERS';
|
||||
const PRAGMA_BLOCKS = 'BLOCKS';
|
||||
|
@ -38,7 +38,7 @@ class Mustache_Source_FilesystemSource implements Mustache_Source
|
||||
/**
|
||||
* Get the Source key (used to generate the compiled class name).
|
||||
*
|
||||
* @throws RuntimeException when a source file cannot be read
|
||||
* @throws Mustache_Exception_RuntimeException when a source file cannot be read
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -54,7 +54,7 @@ class Mustache_Source_FilesystemSource implements Mustache_Source
|
||||
}
|
||||
|
||||
if ($this->stat === false) {
|
||||
throw new RuntimeException(sprintf('Failed to read source file "%s".', $this->fileName));
|
||||
throw new Mustache_Exception_RuntimeException(sprintf('Failed to read source file "%s".', $this->fileName));
|
||||
}
|
||||
|
||||
foreach ($this->statProps as $prop) {
|
||||
|
@ -88,11 +88,11 @@ class Mustache_Tokenizer
|
||||
* @throws Mustache_Exception_InvalidArgumentException when $delimiters string is invalid
|
||||
*
|
||||
* @param string $text Mustache template source to tokenize
|
||||
* @param string $delimiters Optionally, pass initial opening and closing delimiters (default: null)
|
||||
* @param string $delimiters Optionally, pass initial opening and closing delimiters (default: empty string)
|
||||
*
|
||||
* @return array Set of Mustache tokens
|
||||
*/
|
||||
public function scan($text, $delimiters = null)
|
||||
public function scan($text, $delimiters = '')
|
||||
{
|
||||
// Setting mbstring.func_overload makes things *really* slow.
|
||||
// Let's do everyone a favor and scan this string as ASCII instead.
|
||||
@ -112,7 +112,7 @@ class Mustache_Tokenizer
|
||||
|
||||
$this->reset();
|
||||
|
||||
if ($delimiters = trim($delimiters)) {
|
||||
if (is_string($delimiters) && $delimiters = trim($delimiters)) {
|
||||
$this->setDelimiters($delimiters);
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ All rights reserved.</copyright>
|
||||
<location>mustache</location>
|
||||
<name>Mustache</name>
|
||||
<description>PHP library for displaying mustache templates.</description>
|
||||
<version>2.13.0</version>
|
||||
<version>2.14.1</version>
|
||||
<license>MIT</license>
|
||||
<repository>https://github.com/bobthecow/mustache.php</repository>
|
||||
<copyrights>
|
||||
|
Loading…
x
Reference in New Issue
Block a user