|
@@ -7,6 +7,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
use Symfony\Bundle\TwigBundle\TokenParser\IncludeTokenParser;
|
|
use Symfony\Bundle\TwigBundle\TokenParser\IncludeTokenParser;
|
|
use Symfony\Bundle\TwigBundle\TokenParser\UrlTokenParser;
|
|
use Symfony\Bundle\TwigBundle\TokenParser\UrlTokenParser;
|
|
use Symfony\Bundle\TwigBundle\TokenParser\PathTokenParser;
|
|
use Symfony\Bundle\TwigBundle\TokenParser\PathTokenParser;
|
|
|
|
+use Symfony\Component\Yaml\Dumper as YamlDumper;
|
|
|
|
|
|
/*
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
* This file is part of the Symfony package.
|
|
@@ -42,6 +43,16 @@ class TemplatingExtension extends \Twig_Extension
|
|
return $this->templating;
|
|
return $this->templating;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritdoc}
|
|
|
|
+ */
|
|
|
|
+ public function getFilters()
|
|
|
|
+ {
|
|
|
|
+ return array(
|
|
|
|
+ 'yaml' => new \Twig_Filter_Method($this, 'yaml'),
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Returns the token parser instance to add to the existing list.
|
|
* Returns the token parser instance to add to the existing list.
|
|
*
|
|
*
|
|
@@ -82,6 +93,17 @@ class TemplatingExtension extends \Twig_Extension
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function yaml($input, $inline = 0)
|
|
|
|
+ {
|
|
|
|
+ static $dumper;
|
|
|
|
+
|
|
|
|
+ if (null === $dumper) {
|
|
|
|
+ $dumper = new YamlDumper();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $dumper->dump($input, $inline);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Returns the name of the extension.
|
|
* Returns the name of the extension.
|
|
*
|
|
*
|