mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +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
754b7af680
commit
e851106c8f
8 changed files with 21 additions and 23 deletions
|
@ -17,9 +17,3 @@ Local changes:
|
||||||
Note: All this changes need to be reviewed on every upgrade and, if they have
|
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
|
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.
|
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
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function cache($key, $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.
|
* 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 string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -286,7 +286,6 @@ class Mustache_Compiler
|
||||||
private function blockArg($nodes, $id, $start, $end, $otag, $ctag, $level)
|
private function blockArg($nodes, $id, $start, $end, $otag, $ctag, $level)
|
||||||
{
|
{
|
||||||
$key = $this->block($nodes);
|
$key = $this->block($nodes);
|
||||||
$keystr = var_export($key, true);
|
|
||||||
$id = var_export($id, true);
|
$id = var_export($id, true);
|
||||||
|
|
||||||
return sprintf($this->prepare(self::BLOCK_ARG, $level), $id, $key);
|
return sprintf($this->prepare(self::BLOCK_ARG, $level), $id, $key);
|
||||||
|
@ -321,7 +320,6 @@ class Mustache_Compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
const SECTION_CALL = '
|
const SECTION_CALL = '
|
||||||
// %s section
|
|
||||||
$value = $context->%s(%s);%s
|
$value = $context->%s(%s);%s
|
||||||
$buffer .= $this->section%s($context, $indent, $value);
|
$buffer .= $this->section%s($context, $indent, $value);
|
||||||
';
|
';
|
||||||
|
@ -333,12 +331,12 @@ class Mustache_Compiler
|
||||||
|
|
||||||
if (%s) {
|
if (%s) {
|
||||||
$source = %s;
|
$source = %s;
|
||||||
$result = call_user_func($value, $source, %s);
|
$result = (string) call_user_func($value, $source, %s);
|
||||||
if (strpos($result, \'{{\') === false) {
|
if (strpos($result, \'{{\') === false) {
|
||||||
$buffer .= $result;
|
$buffer .= $result;
|
||||||
} else {
|
} else {
|
||||||
$buffer .= $this->mustache
|
$buffer .= $this->mustache
|
||||||
->loadLambda((string) $result%s)
|
->loadLambda($result%s)
|
||||||
->renderInternal($context);
|
->renderInternal($context);
|
||||||
}
|
}
|
||||||
} elseif (!empty($value)) {
|
} elseif (!empty($value)) {
|
||||||
|
@ -392,11 +390,10 @@ class Mustache_Compiler
|
||||||
$id = var_export($id, true);
|
$id = var_export($id, true);
|
||||||
$filters = $this->getFilters($filters, $level);
|
$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 = '
|
const INVERTED_SECTION = '
|
||||||
// %s inverted section
|
|
||||||
$value = $context->%s(%s);%s
|
$value = $context->%s(%s);%s
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
%s
|
%s
|
||||||
|
@ -419,7 +416,7 @@ class Mustache_Compiler
|
||||||
$id = var_export($id, true);
|
$id = var_export($id, true);
|
||||||
$filters = $this->getFilters($filters, $level);
|
$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';
|
const PARTIAL_INDENT = ', $indent . %s';
|
||||||
|
@ -507,7 +504,7 @@ class Mustache_Compiler
|
||||||
|
|
||||||
const VARIABLE = '
|
const VARIABLE = '
|
||||||
$value = $this->resolveValue($context->%s(%s), $context);%s
|
$value = $this->resolveValue($context->%s(%s), $context);%s
|
||||||
$buffer .= %s%s;
|
$buffer .= %s($value === null ? \'\' : %s);
|
||||||
';
|
';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
*/
|
*/
|
||||||
class Mustache_Engine
|
class Mustache_Engine
|
||||||
{
|
{
|
||||||
const VERSION = '2.13.0';
|
const VERSION = '2.14.0';
|
||||||
const SPEC_VERSION = '1.1.2';
|
const SPEC_VERSION = '1.2.2';
|
||||||
|
|
||||||
const PRAGMA_FILTERS = 'FILTERS';
|
const PRAGMA_FILTERS = 'FILTERS';
|
||||||
const PRAGMA_BLOCKS = 'BLOCKS';
|
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).
|
* 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
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +54,7 @@ class Mustache_Source_FilesystemSource implements Mustache_Source
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->stat === false) {
|
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) {
|
foreach ($this->statProps as $prop) {
|
||||||
|
|
|
@ -88,11 +88,11 @@ class Mustache_Tokenizer
|
||||||
* @throws Mustache_Exception_InvalidArgumentException when $delimiters string is invalid
|
* @throws Mustache_Exception_InvalidArgumentException when $delimiters string is invalid
|
||||||
*
|
*
|
||||||
* @param string $text Mustache template source to tokenize
|
* @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
|
* @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.
|
// Setting mbstring.func_overload makes things *really* slow.
|
||||||
// Let's do everyone a favor and scan this string as ASCII instead.
|
// Let's do everyone a favor and scan this string as ASCII instead.
|
||||||
|
@ -112,7 +112,7 @@ class Mustache_Tokenizer
|
||||||
|
|
||||||
$this->reset();
|
$this->reset();
|
||||||
|
|
||||||
if ($delimiters = trim($delimiters)) {
|
if (is_string($delimiters) && $delimiters = trim($delimiters)) {
|
||||||
$this->setDelimiters($delimiters);
|
$this->setDelimiters($delimiters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
<location>mustache</location>
|
<location>mustache</location>
|
||||||
<name>Mustache</name>
|
<name>Mustache</name>
|
||||||
<license>MIT</license>
|
<license>MIT</license>
|
||||||
<version>2.13.0</version>
|
<version>2.14.1</version>
|
||||||
</library>
|
</library>
|
||||||
<library>
|
<library>
|
||||||
<location>amd/src/mustache.js</location>
|
<location>amd/src/mustache.js</location>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue