mirror of
https://github.com/getgrav/grav.git
synced 2026-05-06 12:06:40 +02:00
Added |yaml filter to convert input to YAML
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
# v1.7.21
|
||||
## mm/dd/2021
|
||||
|
||||
1. [](#bugfix)
|
||||
1. [](#new)
|
||||
* Added `|yaml` filter to convert input to YAML
|
||||
3. [](#bugfix)
|
||||
* Fixed escaping in PageIndex::getLevelListing()
|
||||
* Fixed validation of `number` type [#3433](https://github.com/getgrav/grav/issues/3433)
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
|
||||
new TwigFilter('bool', [$this, 'boolFilter']),
|
||||
new TwigFilter('float', [$this, 'floatFilter'], ['is_safe' => ['all']]),
|
||||
new TwigFilter('array', [$this, 'arrayFilter']),
|
||||
new TwigFilter('yaml', [$this, 'yamlFilter']),
|
||||
|
||||
// Object Types
|
||||
new TwigFilter('get_type', [$this, 'getTypeFunc']),
|
||||
@@ -807,6 +808,17 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
|
||||
return (array)$input;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|object $value
|
||||
* @param int|null $inline
|
||||
* @param int|null $indent
|
||||
* @return string
|
||||
*/
|
||||
public function yamlFilter($value, $inline = null, $indent = null): string
|
||||
{
|
||||
return Yaml::dump($value, $inline, $indent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Environment $twig
|
||||
* @return string
|
||||
|
||||
Reference in New Issue
Block a user