diff --git a/lib/mustache/readme_moodle.txt b/lib/mustache/readme_moodle.txt
index 912fc862690..e443e5893ce 100644
--- a/lib/mustache/readme_moodle.txt
+++ b/lib/mustache/readme_moodle.txt
@@ -10,6 +10,8 @@ Delete phpunit.xml.dist
Delete hidden files ".*"
+Delete hidden directories ".git"
+
Delete folder "bin"
Delete folder "vendor"
@@ -17,3 +19,7 @@ Delete folder "vendor"
Delete composer.json
Copy into this folder, and update this readme to cover any changes.
+
+== 3.1 ==
+
+Update from version 2.9.0 to 2.10.0
diff --git a/lib/mustache/src/Mustache/Compiler.php b/lib/mustache/src/Mustache/Compiler.php
index 7d5c96b56ee..76e580c7f2b 100644
--- a/lib/mustache/src/Mustache/Compiler.php
+++ b/lib/mustache/src/Mustache/Compiler.php
@@ -328,7 +328,7 @@ class Mustache_Compiler
$buffer = \'\';
if (%s) {
$source = %s;
- $result = call_user_func($value, $source, $this->lambdaHelper);
+ $result = call_user_func($value, $source, %s);
if (strpos($result, \'{{\') === false) {
$buffer .= $result;
} else {
@@ -370,15 +370,18 @@ class Mustache_Compiler
$callable = $this->getCallable();
if ($otag !== '{{' || $ctag !== '}}') {
- $delims = ', ' . var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true);
+ $delimTag = var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true);
+ $helper = sprintf('$this->lambdaHelper->withDelimiters(%s)', $delimTag);
+ $delims = ', ' . $delimTag;
} else {
+ $helper = '$this->lambdaHelper';
$delims = '';
}
$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));
+ $this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $helper, $delims, $this->walk($nodes, 2));
}
if ($arg === true) {
@@ -495,7 +498,7 @@ class Mustache_Compiler
}
const VARIABLE = '
- $value = $this->resolveValue($context->%s(%s), $context, $indent);%s
+ $value = $this->resolveValue($context->%s(%s), $context);%s
$buffer .= %s%s;
';
diff --git a/lib/mustache/src/Mustache/Engine.php b/lib/mustache/src/Mustache/Engine.php
index 08bcc810f3d..fe119121895 100644
--- a/lib/mustache/src/Mustache/Engine.php
+++ b/lib/mustache/src/Mustache/Engine.php
@@ -23,7 +23,7 @@
*/
class Mustache_Engine
{
- const VERSION = '2.9.0';
+ const VERSION = '2.10.0';
const SPEC_VERSION = '1.1.2';
const PRAGMA_FILTERS = 'FILTERS';
diff --git a/lib/mustache/src/Mustache/LambdaHelper.php b/lib/mustache/src/Mustache/LambdaHelper.php
index de48fd63335..cb8e96698fa 100644
--- a/lib/mustache/src/Mustache/LambdaHelper.php
+++ b/lib/mustache/src/Mustache/LambdaHelper.php
@@ -20,17 +20,20 @@ class Mustache_LambdaHelper
{
private $mustache;
private $context;
+ private $delims;
/**
* Mustache Lambda Helper constructor.
*
* @param Mustache_Engine $mustache Mustache engine instance.
* @param Mustache_Context $context Rendering context.
+ * @param string $delims Optional custom delimiters, in the format `{{= <% %> =}}`. (default: null)
*/
- public function __construct(Mustache_Engine $mustache, Mustache_Context $context)
+ public function __construct(Mustache_Engine $mustache, Mustache_Context $context, $delims = null)
{
$this->mustache = $mustache;
$this->context = $context;
+ $this->delims = $delims;
}
/**
@@ -43,7 +46,31 @@ class Mustache_LambdaHelper
public function render($string)
{
return $this->mustache
- ->loadLambda((string) $string)
+ ->loadLambda((string) $string, $this->delims)
->renderInternal($this->context);
}
+
+ /**
+ * Render a string as a Mustache template with the current rendering context.
+ *
+ * @param string $string
+ *
+ * @return string Rendered template
+ */
+ public function __invoke($string)
+ {
+ return $this->render($string);
+ }
+
+ /**
+ * Get a Lambda Helper with custom delimiters.
+ *
+ * @param string $delims Custom delimiters, in the format `{{= <% %> =}}`.
+ *
+ * @return Mustache_LambdaHelper
+ */
+ public function withDelimiters($delims)
+ {
+ return new self($this->mustache, $this->context, $delims);
+ }
}
diff --git a/lib/mustache/src/Mustache/Template.php b/lib/mustache/src/Mustache/Template.php
index 91074c448e3..f2d198f22c3 100644
--- a/lib/mustache/src/Mustache/Template.php
+++ b/lib/mustache/src/Mustache/Template.php
@@ -164,16 +164,15 @@ abstract class Mustache_Template
*
* @param mixed $value
* @param Mustache_Context $context
- * @param string $indent
*
* @return string
*/
- protected function resolveValue($value, Mustache_Context $context, $indent = '')
+ protected function resolveValue($value, Mustache_Context $context)
{
if (($this->strictCallables ? is_object($value) : !is_string($value)) && is_callable($value)) {
return $this->mustache
->loadLambda((string) call_user_func($value))
- ->renderInternal($context, $indent);
+ ->renderInternal($context);
}
return $value;
diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml
index df2969fe83f..382f190e9f0 100644
--- a/lib/thirdpartylibs.xml
+++ b/lib/thirdpartylibs.xml
@@ -255,7 +255,7 @@
mustache
Mustache
MIT
- 2.9.0
+ 2.10.0
amd/src/mustache.js