From b9afa84571016cc60ffd2e221d0def3a0fdb543f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 17 Jul 2012 08:23:39 +0200 Subject: [PATCH] renamed the default filesystem namespace to __main__ --- lib/Twig/Loader/Filesystem.php | 10 +++++----- test/Twig/Tests/Loader/FilesystemTest.php | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 2be0d90..08e1f73 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -37,7 +37,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface * * @return array The array of paths where to look for templates */ - public function getPaths($namespace = '') + public function getPaths($namespace = '__main__') { return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array(); } @@ -48,7 +48,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface * @param string|array $paths A path or an array of paths where to look for templates * @param string $namespace A path namespace */ - public function setPaths($paths, $namespace = '') + public function setPaths($paths, $namespace = '__main__') { if (!is_array($paths)) { $paths = array($paths); @@ -66,7 +66,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface * @param string $path A path where to look for templates * @param string $namespace A path name */ - public function addPath($path, $namespace = '') + public function addPath($path, $namespace = '__main__') { // invalidate the cache $this->cache = array(); @@ -84,7 +84,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface * @param string $path A path where to look for templates * @param string $namespace A path name */ - public function prependPath($path, $namespace = '') + public function prependPath($path, $namespace = '__main__') { // invalidate the cache $this->cache = array(); @@ -142,7 +142,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface $this->validateName($name); - $namespace = ''; + $namespace = '__main__'; if (isset($name[0]) && '@' == $name[0]) { if (false === $pos = strpos($name, '/')) { throw new \InvalidArgumentException(sprintf('Malformed template name "%s".', $name)); diff --git a/test/Twig/Tests/Loader/FilesystemTest.php b/test/Twig/Tests/Loader/FilesystemTest.php index ffc4fb7..85bb6e5 100644 --- a/test/Twig/Tests/Loader/FilesystemTest.php +++ b/test/Twig/Tests/Loader/FilesystemTest.php @@ -75,6 +75,7 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase ), $loader->getPaths('named')); $this->assertEquals("path (final)\n", $loader->getSource('index.html')); + $this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html')); $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html')); } } -- 1.7.2.5