Fixed print_r() in twig

This commit is contained in:
Matias Griese
2020-10-18 20:17:17 +03:00
parent 972d32c969
commit c0d819b97a
2 changed files with 8 additions and 2 deletions

View File

@@ -9,6 +9,7 @@
* Accessing page with unsupported file extension (jpg, pdf, xsl) will use wrong mime type [#3031](https://github.com/getgrav/grav/issues/3031)
* Fixed media crashing on a bad image
* Fixed bug in collections where filter `type: false` did not work
* Fixed `print_r()` in twig
# v1.7.0-rc.17
## 10/07/2020

View File

@@ -140,7 +140,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
new TwigFilter('array_unique', 'array_unique'),
new TwigFilter('basename', 'basename'),
new TwigFilter('dirname', 'dirname'),
new TwigFilter('print_r', 'print_r'),
new TwigFilter('print_r', [$this, 'print_r']),
new TwigFilter('yaml_encode', [$this, 'yamlEncodeFilter']),
new TwigFilter('yaml_decode', [$this, 'yamlDecodeFilter']),
new TwigFilter('nicecron', [$this, 'niceCronFilter']),
@@ -181,7 +181,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
new TwigFunction('debug', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new TwigFunction('dump', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new TwigFunction('vardump', [$this, 'vardumpFunc']),
new TwigFunction('print_r', 'print_r'),
new TwigFunction('print_r', [$this, 'print_r']),
new TwigFunction('http_response_code', 'http_response_code'),
new TwigFunction('evaluate', [$this, 'evaluateStringFunc'], ['needs_context' => true]),
new TwigFunction('evaluate_twig', [$this, 'evaluateTwigFunc'], ['needs_context' => true]),
@@ -241,6 +241,11 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
];
}
public function print_r($var)
{
return print_r($var, true);
}
/**
* Filters field name by changing dot notation into array notation.
*