Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[TwigBundle] added a new paths setting to allow configuration of more…
… paths for the filesystem loader (refs #4649)
  • Loading branch information
fabpot committed Jul 9, 2012
1 parent 8f267ad commit 39e821c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Symfony/Bundle/TwigBundle/CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
2.1.0
-----

* added a new setting ("paths") to configure more paths for the Twig filesystem loader
* added contextual escaping based on the template file name (disabled if you explicitly pass an autoescape option)
* added a command that extracts translation messages from templates
* added the real template name when an error occurs in a Twig template
Expand Down
Expand Up @@ -115,6 +115,7 @@ private function addGlobalsSection(ArrayNodeDefinition $rootNode)
private function addTwigOptions(ArrayNodeDefinition $rootNode)
{
$rootNode
->fixXmlConfig('path')
->children()
->scalarNode('autoescape')->end()
->scalarNode('base_template_class')->example('Twig_Template')->end()
Expand All @@ -124,7 +125,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode)
->scalarNode('strict_variables')->end()
->scalarNode('auto_reload')->end()
->scalarNode('optimizations')->end()
->arrayNode('loader_paths')
->arrayNode('paths')
->prototype('variable')->end()
->end()
->end()
Expand Down
Expand Up @@ -60,8 +60,8 @@ public function load(array $configs, ContainerBuilder $container)
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));

if (!empty($config['loader_paths'])) {
foreach ($config['loader_paths'] as $path) {
if (!empty($config['paths'])) {
foreach ($config['paths'] as $path) {
$container->getDefinition('twig.loader')->addMethodCall('addPath', array($path));
}
}
Expand Down
Expand Up @@ -11,6 +11,7 @@
<xsd:sequence>
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
<xsd:element name="global" type="global" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="path" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>

<xsd:attribute name="auto-reload" type="xsd:string" />
Expand Down
Expand Up @@ -18,4 +18,5 @@
'charset' => 'ISO-8859-1',
'debug' => true,
'strict_variables' => true,
'paths' => array('path1', 'path2'),
));
Expand Up @@ -12,5 +12,7 @@
</twig:form>
<twig:global key="foo" id="bar" type="service" />
<twig:global key="pi">3.14</twig:global>
<twig:path>path1</twig:path>
<twig:path>path2</twig:path>
</twig:config>
</container>
Expand Up @@ -13,3 +13,4 @@ twig:
charset: ISO-8859-1
debug: true
strict_variables: true
paths: [path1, path2]

0 comments on commit 39e821c

Please sign in to comment.