Skip to content
This repository
Browse code

Merge pull request #85 from bobthecow/feature/5.2-support

Make this hotness work with PHP 5.2
  • Loading branch information...
commit b7a6ff243392a43be7d206cfa9a72b42eae211d0 2 parents 99ff731 + 21d2b9b
Justin Hileman authored March 17, 2012

Showing 35 changed files with 353 additions and 492 deletions. Show diff stats Hide diff stats

  1. 4  README.markdown
  2. 2  composer.json
  3. 18  src/Mustache/Autoloader.php
  4. 62  src/Mustache/Compiler.php
  5. 6  src/Mustache/Context.php
  6. 26  src/Mustache/HelperCollection.php
  7. 4  src/Mustache/Loader.php
  8. 11  src/Mustache/Loader/ArrayLoader.php
  9. 24  src/Mustache/Loader/FilesystemLoader.php
  10. 4  src/Mustache/Loader/MutableLoader.php
  11. 6  src/Mustache/Loader/StringLoader.php
  12. 112  src/Mustache/Mustache.php
  13. 32  src/Mustache/Parser.php
  14. 24  src/Mustache/Template.php
  15. 4  src/Mustache/Tokenizer.php
  16. 18  test/Mustache/Test/AutoloaderTest.php
  17. 29  test/Mustache/Test/CompilerTest.php
  18. 28  test/Mustache/Test/ContextTest.php
  19. 12  test/Mustache/Test/Functional/CallTest.php
  20. 10  test/Mustache/Test/Functional/ExamplesTest.php
  21. 26  test/Mustache/Test/Functional/HigherOrderSectionsTest.php
  22. 8  test/Mustache/Test/Functional/MustacheInjectionTest.php
  23. 15  test/Mustache/Test/Functional/MustacheSpecTest.php
  24. 32  test/Mustache/Test/Functional/ObjectSectionTest.php
  25. 14  test/Mustache/Test/HelperCollectionTest.php
  26. 12  test/Mustache/Test/Loader/ArrayLoaderTest.php
  27. 20  test/Mustache/Test/Loader/FilesystemLoaderTest.php
  28. 8  test/Mustache/Test/Loader/StringLoaderTest.php
  29. 69  test/Mustache/Test/MustacheTest.php
  30. 91  test/Mustache/Test/ParserTest.php
  31. 22  test/Mustache/Test/TemplateTest.php
  32. 78  test/Mustache/Test/TokenizerTest.php
  33. 6  test/bootstrap.php
  34. 4  test/fixtures/autoloader/Mustache/Bar.php
  35. 4  test/fixtures/autoloader/Mustache/Foo.php
4  README.markdown
Source Rendered
@@ -11,7 +11,7 @@ A quick example:
11 11
 
12 12
 ```php
13 13
 <?php
14  
-$m = new Mustache;
  14
+$m = new Mustache_Mustache;
15 15
 echo $m->render('Hello {{planet}}', array('planet' => 'World!')); // "Hello World!"
16 16
 ```
17 17
 
@@ -48,7 +48,7 @@ And render it:
48 48
 
49 49
 ```php
50 50
 <?php
51  
-$m = new Mustache;
  51
+$m = new Mustache_Mustache;
52 52
 $chris = new Chris;
53 53
 echo $m->render($template, $chris);
54 54
 ```
2  composer.json
@@ -13,7 +13,7 @@
13 13
         }
14 14
     ],
15 15
     "require": {
16  
-        "php": ">=5.3.0"
  16
+        "php": ">=5.2.4"
17 17
     },
18 18
     "autoload": {
19 19
         "psr-0": { "Mustache": "src/" }
18  src/Mustache/Autoloader.php
@@ -9,30 +9,32 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14 12
 /**
15 13
  * Mustache class autoloader.
16 14
  */
17  
-class Autoloader {
  15
+class Mustache_Autoloader {
18 16
 
19 17
 	private $baseDir;
20 18
 
21 19
 	/**
22 20
 	 * Autoloader constructor.
23 21
 	 *
24  
-	 * @param string $baseDir Mustache library base directory (default: __DIR__.'/..')
  22
+	 * @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
25 23
 	 */
26 24
 	public function __construct($baseDir = null) {
27  
-		$this->baseDir = rtrim($baseDir, '/') ?: __DIR__.'/..';
  25
+		if ($baseDir === null) {
  26
+			$this->baseDir = dirname(__FILE__).'/..';
  27
+		} else {
  28
+			$this->baseDir = rtrim($baseDir, '/');
  29
+		}
28 30
 	}
29 31
 
30 32
 	/**
31 33
 	 * Register a new instance as an SPL autoloader.
32 34
 	 *
33  
-	 * @param string $baseDir Mustache library base directory (default: __DIR__.'/..')
  35
+	 * @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
34 36
 	 *
35  
-	 * @return \Mustache\Autoloader Registered Autoloader instance
  37
+	 * @return Mustache_Autoloader Registered Autoloader instance
36 38
 	 */
37 39
 	static public function register($baseDir = null) {
38 40
 		$loader = new self($baseDir);
@@ -55,7 +57,7 @@ public function autoload($class) {
55 57
 			return;
56 58
 		}
57 59
 
58  
-		$file = sprintf('%s/%s.php', $this->baseDir, str_replace('\\', '/', $class));
  60
+		$file = sprintf('%s/%s.php', $this->baseDir, str_replace('_', '/', $class));
59 61
 		if (is_file($file)) {
60 62
 			require $file;
61 63
 		}
62  src/Mustache/Compiler.php
@@ -9,14 +9,12 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14 12
 /**
15 13
  * Mustache Compiler class.
16 14
  *
17 15
  * This class is responsible for turning a Mustache token parse tree into normal PHP source code.
18 16
  */
19  
-class Compiler {
  17
+class Mustache_Compiler {
20 18
 
21 19
 	private $sections;
22 20
 	private $source;
@@ -46,7 +44,7 @@ public function compile($source, array $tree, $name, $customEscape = false, $cha
46 44
 	/**
47 45
 	 * Helper function for walking the Mustache token parse tree.
48 46
 	 *
49  
-	 * @throws \InvalidArgumentException upon encountering unknown token types.
  47
+	 * @throws InvalidArgumentException upon encountering unknown token types.
50 48
 	 *
51 49
 	 * @param array $tree  Parse tree of Mustache tokens
52 50
 	 * @param int   $level (default: 0)
@@ -57,46 +55,46 @@ private function walk(array $tree, $level = 0) {
57 55
 		$code = '';
58 56
 		$level++;
59 57
 		foreach ($tree as $node) {
60  
-			switch (is_string($node) ? 'text' : $node[Tokenizer::TYPE]) {
61  
-				case Tokenizer::T_SECTION:
  58
+			switch (is_string($node) ? 'text' : $node[Mustache_Tokenizer::TYPE]) {
  59
+				case Mustache_Tokenizer::T_SECTION:
62 60
 					$code .= $this->section(
63  
-						$node[Tokenizer::NODES],
64  
-						$node[Tokenizer::NAME],
65  
-						$node[Tokenizer::INDEX],
66  
-						$node[Tokenizer::END],
67  
-						$node[Tokenizer::OTAG],
68  
-						$node[Tokenizer::CTAG],
  61
+						$node[Mustache_Tokenizer::NODES],
  62
+						$node[Mustache_Tokenizer::NAME],
  63
+						$node[Mustache_Tokenizer::INDEX],
  64
+						$node[Mustache_Tokenizer::END],
  65
+						$node[Mustache_Tokenizer::OTAG],
  66
+						$node[Mustache_Tokenizer::CTAG],
69 67
 						$level
70 68
 					);
71 69
 					break;
72 70
 
73  
-				case Tokenizer::T_INVERTED:
  71
+				case Mustache_Tokenizer::T_INVERTED:
74 72
 					$code .= $this->invertedSection(
75  
-						$node[Tokenizer::NODES],
76  
-						$node[Tokenizer::NAME],
  73
+						$node[Mustache_Tokenizer::NODES],
  74
+						$node[Mustache_Tokenizer::NAME],
77 75
 						$level
78 76
 					);
79 77
 					break;
80 78
 
81  
-				case Tokenizer::T_PARTIAL:
82  
-				case Tokenizer::T_PARTIAL_2:
  79
+				case Mustache_Tokenizer::T_PARTIAL:
  80
+				case Mustache_Tokenizer::T_PARTIAL_2:
83 81
 					$code .= $this->partial(
84  
-						$node[Tokenizer::NAME],
85  
-						isset($node[Tokenizer::INDENT]) ? $node[Tokenizer::INDENT] : '',
  82
+						$node[Mustache_Tokenizer::NAME],
  83
+						isset($node[Mustache_Tokenizer::INDENT]) ? $node[Mustache_Tokenizer::INDENT] : '',
86 84
 						$level
87 85
 					);
88 86
 					break;
89 87
 
90  
-				case Tokenizer::T_UNESCAPED:
91  
-				case Tokenizer::T_UNESCAPED_2:
92  
-					$code .= $this->variable($node[Tokenizer::NAME], false, $level);
  88
+				case Mustache_Tokenizer::T_UNESCAPED:
  89
+				case Mustache_Tokenizer::T_UNESCAPED_2:
  90
+					$code .= $this->variable($node[Mustache_Tokenizer::NAME], false, $level);
93 91
 					break;
94 92
 
95  
-				case Tokenizer::T_COMMENT:
  93
+				case Mustache_Tokenizer::T_COMMENT:
96 94
 					break;
97 95
 
98  
-				case Tokenizer::T_ESCAPED:
99  
-					$code .= $this->variable($node[Tokenizer::NAME], true, $level);
  96
+				case Mustache_Tokenizer::T_ESCAPED:
  97
+					$code .= $this->variable($node[Mustache_Tokenizer::NAME], true, $level);
100 98
 					break;
101 99
 
102 100
 
@@ -105,7 +103,7 @@ private function walk(array $tree, $level = 0) {
105 103
 					break;
106 104
 
107 105
 				default:
108  
-					throw new \InvalidArgumentException('Unknown node type: '.json_encode($node));
  106
+					throw new InvalidArgumentException('Unknown node type: '.json_encode($node));
109 107
 			}
110 108
 		}
111 109
 
@@ -114,8 +112,8 @@ private function walk(array $tree, $level = 0) {
114 112
 
115 113
 	const KLASS = '<?php
116 114
 
117  
-		class %s extends \Mustache\Template {
118  
-			public function renderInternal(\Mustache\Context $context, $indent = \'\', $escape = false) {
  115
+		class %s extends Mustache_Template {
  116
+			public function renderInternal(Mustache_Context $context, $indent = \'\', $escape = false) {
119 117
 				$buffer = \'\';
120 118
 		%s
121 119
 
@@ -149,7 +147,7 @@ private function writeCode($tree, $name) {
149 147
 	';
150 148
 
151 149
 	const SECTION = '
152  
-		private function section%s(\Mustache\Context $context, $indent, $value) {
  150
+		private function section%s(Mustache_Context $context, $indent, $value) {
153 151
 			$buffer = \'\';
154 152
 			if (!is_string($value) && is_callable($value)) {
155 153
 				$source = %s;
@@ -329,9 +327,9 @@ private function getEscape($value = '$value') {
329 327
 	 *
330 328
 	 * The return value will be one of `find`, `findDot` or `last`.
331 329
 	 *
332  
-	 * @see \Mustache\Context::find
333  
-	 * @see \Mustache\Context::findDot
334  
-	 * @see \Mustache\Context::last
  330
+	 * @see Mustache_Context::find
  331
+	 * @see Mustache_Context::findDot
  332
+	 * @see Mustache_Context::last
335 333
 	 *
336 334
 	 * @param string $id Variable name
337 335
 	 *
6  src/Mustache/Context.php
@@ -9,12 +9,10 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14 12
 /**
15 13
  * Mustache Template rendering Context.
16 14
  */
17  
-class Context {
  15
+class Mustache_Context {
18 16
 	private $stack = array();
19 17
 
20 18
 	/**
@@ -118,7 +116,7 @@ public function findDot($id) {
118 116
 	/**
119 117
 	 * Helper function to find a variable in the Context stack.
120 118
 	 *
121  
-	 * @see \Mustache\Context::find
  119
+	 * @see Mustache_Context::find
122 120
 	 *
123 121
 	 * @param string $id    Variable name
124 122
 	 * @param array  $stack Context stack
26  src/Mustache/HelperCollection.php
@@ -9,27 +9,25 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14 12
 /**
15 13
  * A collection of helpers for a Mustache instance.
16 14
  */
17  
-class HelperCollection {
  15
+class Mustache_HelperCollection {
18 16
 	private $helpers = array();
19 17
 
20 18
 	/**
21 19
 	 * Helper Collection constructor.
22 20
 	 *
23  
-	 * Optionally accepts an array (or \Traversable) of `$name => $helper` pairs.
  21
+	 * Optionally accepts an array (or Traversable) of `$name => $helper` pairs.
24 22
 	 *
25  
-	 * @throws \InvalidArgumentException if the $helpers argument isn't an array or \Traversable
  23
+	 * @throws InvalidArgumentException if the $helpers argument isn't an array or Traversable
26 24
 	 *
27 25
 	 * @param array|Traversable $helpers (default: null)
28 26
 	 */
29 27
 	public function __construct($helpers = null) {
30 28
 		if ($helpers !== null) {
31  
-			if (!is_array($helpers) && !$helpers instanceof \Traversable) {
32  
-				throw new \InvalidArgumentException('HelperCollection constructor expects an array of helpers');
  29
+			if (!is_array($helpers) && !$helpers instanceof Traversable) {
  30
+				throw new InvalidArgumentException('HelperCollection constructor expects an array of helpers');
33 31
 			}
34 32
 
35 33
 			foreach ($helpers as $name => $helper) {
@@ -41,7 +39,7 @@ public function __construct($helpers = null) {
41 39
 	/**
42 40
 	 * Magic mutator.
43 41
 	 *
44  
-	 * @see \Mustache\HelperCollection::add
  42
+	 * @see Mustache_HelperCollection::add
45 43
 	 *
46 44
 	 * @param string $name
47 45
 	 * @param mixed  $helper
@@ -63,7 +61,7 @@ public function add($name, $helper) {
63 61
 	/**
64 62
 	 * Magic accessor.
65 63
 	 *
66  
-	 * @see \Mustache\HelperCollection::get
  64
+	 * @see Mustache_HelperCollection::get
67 65
 	 *
68 66
 	 * @param string $name
69 67
 	 *
@@ -82,7 +80,7 @@ public function __get($name) {
82 80
 	 */
83 81
 	public function get($name) {
84 82
 		if (!$this->has($name)) {
85  
-			throw new \InvalidArgumentException('Unknown helper: '.$name);
  83
+			throw new InvalidArgumentException('Unknown helper: '.$name);
86 84
 		}
87 85
 
88 86
 		return $this->helpers[$name];
@@ -91,7 +89,7 @@ public function get($name) {
91 89
 	/**
92 90
 	 * Magic isset().
93 91
 	 *
94  
-	 * @see \Mustache\HelperCollection::has
  92
+	 * @see Mustache_HelperCollection::has
95 93
 	 *
96 94
 	 * @param string $name
97 95
 	 *
@@ -115,7 +113,7 @@ public function has($name) {
115 113
 	/**
116 114
 	 * Magic unset().
117 115
 	 *
118  
-	 * @see \Mustache\HelperCollection::remove
  116
+	 * @see Mustache_HelperCollection::remove
119 117
 	 *
120 118
 	 * @param string $name
121 119
 	 */
@@ -126,13 +124,13 @@ public function __unset($name) {
126 124
 	/**
127 125
 	 * Check whether a given helper is present in the collection.
128 126
 	 *
129  
-	 * @throws \InvalidArgumentException if the requested helper is not present.
  127
+	 * @throws InvalidArgumentException if the requested helper is not present.
130 128
 	 *
131 129
 	 * @param string $name
132 130
 	 */
133 131
 	public function remove($name) {
134 132
 		if (!$this->has($name)) {
135  
-			throw new \InvalidArgumentException('Unknown helper: '.$name);
  133
+			throw new InvalidArgumentException('Unknown helper: '.$name);
136 134
 		}
137 135
 
138 136
 		unset($this->helpers[$name]);
4  src/Mustache/Loader.php
@@ -9,12 +9,10 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14 12
 /**
15 13
  * Mustache Template Loader interface.
16 14
  */
17  
-interface Loader {
  15
+interface Mustache_Loader {
18 16
 
19 17
 	/**
20 18
 	 * Load a Template by name.
11  src/Mustache/Loader/ArrayLoader.php
@@ -9,11 +9,6 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache\Loader;
13  
-
14  
-use Mustache\Loader;
15  
-use Mustache\Loader\MutableLoader;
16  
-
17 12
 /**
18 13
  * Mustache Template array Loader implementation.
19 14
  *
@@ -26,13 +21,13 @@
26 21
  *
27 22
  *     $tpl = $loader->load('foo'); // '{{ bar }}'
28 23
  *
29  
- * The ArrayLoader is used internally as a partials loader by \Mustache\Mustache instance when an array of partials
  24
+ * The ArrayLoader is used internally as a partials loader by Mustache_Mustache instance when an array of partials
30 25
  * is set. It can also be used as a quick-and-dirty Template loader.
31 26
  *
32 27
  * @implements Loader
33 28
  * @implements MutableLoader
34 29
  */
35  
-class ArrayLoader implements Loader, MutableLoader {
  30
+class Mustache_Loader_ArrayLoader implements Mustache_Loader, Mustache_Loader_MutableLoader {
36 31
 
37 32
 	/**
38 33
 	 * ArrayLoader constructor.
@@ -52,7 +47,7 @@ public function __construct(array $templates = array()) {
52 47
 	 */
53 48
 	public function load($name) {
54 49
 		if (!isset($this->templates[$name])) {
55  
-			throw new \InvalidArgumentException('Template '.$name.' not found.');
  50
+			throw new InvalidArgumentException('Template '.$name.' not found.');
56 51
 		}
57 52
 
58 53
 		return $this->templates[$name];
24  src/Mustache/Loader/FilesystemLoader.php
@@ -9,28 +9,24 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache\Loader;
13  
-
14  
-use Mustache\Loader;
15  
-
16 12
 /**
17 13
  * Mustache Template filesystem Loader implementation.
18 14
  *
19 15
  * An ArrayLoader instance loads Mustache Template source from the filesystem by name:
20 16
  *
21  
- *     $loader = new FilesystemLoader(__DIR__.'/views');
22  
- *     $tpl = $loader->load('foo'); // equivalent to `file_get_contents(__DIR__.'/views/foo.mustache');
  17
+ *     $loader = new FilesystemLoader(dirname(__FILE__).'/views');
  18
+ *     $tpl = $loader->load('foo'); // equivalent to `file_get_contents(dirname(__FILE__).'/views/foo.mustache');
23 19
  *
24 20
  * This is probably the most useful Mustache Loader implementation. It can be used for partials and normal Templates:
25 21
  *
26 22
  *     $m = new Mustache(array(
27  
- *          'loader'          => new FilesystemLoader(__DIR__.'/views'),
28  
- *          'partials_loader' => new FilesystemLoader(__DIR__.'/views/partials'),
  23
+ *          'loader'          => new FilesystemLoader(dirname(__FILE__).'/views'),
  24
+ *          'partials_loader' => new FilesystemLoader(dirname(__FILE__).'/views/partials'),
29 25
  *     ));
30 26
  *
31 27
  * @implements Loader
32 28
  */
33  
-class FilesystemLoader implements Loader {
  29
+class Mustache_Loader_FilesystemLoader implements Mustache_Loader {
34 30
 	private $baseDir;
35 31
 	private $extension = '.mustache';
36 32
 	private $templates = array();
@@ -45,7 +41,7 @@ class FilesystemLoader implements Loader {
45 41
 	 *         'extension' => '.ms',
46 42
 	 *     );
47 43
 	 *
48  
-	 * @throws \RuntimeException if $baseDir does not exist.
  44
+	 * @throws RuntimeException if $baseDir does not exist.
49 45
 	 *
50 46
 	 * @param string $baseDir Base directory containing Mustache template files.
51 47
 	 * @param array  $options Array of Loader options (default: array())
@@ -54,7 +50,7 @@ public function __construct($baseDir, array $options = array()) {
54 50
 		$this->baseDir = rtrim(realpath($baseDir), '/');
55 51
 
56 52
 		if (!is_dir($this->baseDir)) {
57  
-			throw new \RuntimeException('FilesystemLoader baseDir must be a directory: '.$baseDir);
  53
+			throw new RuntimeException('FilesystemLoader baseDir must be a directory: '.$baseDir);
58 54
 		}
59 55
 
60 56
 		if (isset($options['extension'])) {
@@ -65,7 +61,7 @@ public function __construct($baseDir, array $options = array()) {
65 61
 	/**
66 62
 	 * Load a Template by name.
67 63
 	 *
68  
-	 *     $loader = new FilesystemLoader(__DIR__.'/views');
  64
+	 *     $loader = new FilesystemLoader(dirname(__FILE__).'/views');
69 65
 	 *     $loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache";
70 66
 	 *
71 67
 	 * @param string $name
@@ -83,7 +79,7 @@ public function load($name) {
83 79
 	/**
84 80
 	 * Helper function for loading a Mustache file by name.
85 81
 	 *
86  
-	 * @throws \InvalidArgumentException if a template file is not found.
  82
+	 * @throws InvalidArgumentException if a template file is not found.
87 83
 	 *
88 84
 	 * @param string $name
89 85
 	 *
@@ -93,7 +89,7 @@ private function loadFile($name) {
93 89
 		$fileName = $this->getFileName($name);
94 90
 
95 91
 		if (!file_exists($fileName)) {
96  
-			throw new \InvalidArgumentException('Template '.$name.' not found.');
  92
+			throw new InvalidArgumentException('Template '.$name.' not found.');
97 93
 		}
98 94
 
99 95
 		return file_get_contents($fileName);
4  src/Mustache/Loader/MutableLoader.php
@@ -9,12 +9,10 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache\Loader;
13  
-
14 12
 /**
15 13
  * Mustache Template mutable Loader interface.
16 14
  */
17  
-interface MutableLoader {
  15
+interface Mustache_Loader_MutableLoader {
18 16
 
19 17
 	/**
20 18
 	 * Set an associative array of Template sources for this loader.
6  src/Mustache/Loader/StringLoader.php
@@ -9,10 +9,6 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache\Loader;
13  
-
14  
-use Mustache\Loader;
15  
-
16 12
 /**
17 13
  * Mustache Template string Loader implementation.
18 14
  *
@@ -29,7 +25,7 @@
29 25
  *
30 26
  * @implements Loader
31 27
  */
32  
-class StringLoader implements Loader {
  28
+class Mustache_Loader_StringLoader implements Mustache_Loader {
33 29
 
34 30
 	/**
35 31
 	 * Load a Template by source.
112  src/Mustache/Mustache.php
@@ -9,12 +9,6 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14  
-use Mustache\Loader\ArrayLoader;
15  
-use Mustache\Loader\MutableLoader;
16  
-use Mustache\Loader\StringLoader;
17  
-
18 12
 /**
19 13
  * A Mustache implementation in PHP.
20 14
  *
@@ -27,7 +21,7 @@
27 21
  *
28 22
  * @author Justin Hileman {@link http://justinhileman.com}
29 23
  */
30  
-class Mustache {
  24
+class Mustache_Mustache {
31 25
 	const VERSION      = '2.0.0-dev';
32 26
 	const SPEC_VERSION = '1.1.2';
33 27
 
@@ -50,20 +44,20 @@ class Mustache {
50 44
 	 *
51 45
 	 *     $options = array(
52 46
 	 *         // The class prefix for compiled templates. Defaults to '__Mustache_'
53  
-	 *         'template_class_prefix' => '\My\Namespace\Template\',
  47
+	 *         'template_class_prefix' => '__MyTemplates_',
54 48
 	 *
55 49
 	 *         // A cache directory for compiled templates. Mustache will not cache templates unless this is set
56  
-	 *         'cache' => __DIR__.'/tmp/cache/mustache',
  50
+	 *         'cache' => dirname(__FILE__).'/tmp/cache/mustache',
57 51
 	 *
58 52
 	 *         // A Mustache template loader instance. Uses a StringLoader if not specified
59  
-	 *         'loader' => new \Mustache\Loader\FilesystemLoader(__DIR__.'/views'),
  53
+	 *         'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'),
60 54
 	 *
61 55
 	 *         // A Mustache loader instance for partials.
62  
-	 *         'partials_loader' => new \Mustache\Loader\FilesystemLoader(__DIR__.'/views/partials'),
  56
+	 *         'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials'),
63 57
 	 *
64 58
 	 *         // An array of Mustache partials. Useful for quick-and-dirty string template loading, but not as
65 59
 	 *         // efficient or lazy as a Filesystem (or database) loader.
66  
-	 *         'partials' => array('foo' => file_get_contents(__DIR__.'/views/partials/foo.mustache')),
  60
+	 *         'partials' => array('foo' => file_get_contents(dirname(__FILE__).'/views/partials/foo.mustache')),
67 61
 	 *
68 62
 	 *         // An array of 'helpers'. Helpers can be global variables or objects, closures (e.g. for higher order
69 63
 	 *         // sections), or any other valid Mustache context value. They will be prepended to the context stack,
@@ -126,8 +120,8 @@ public function __construct(array $options = array()) {
126 120
 	 *
127 121
 	 * Equivalent to calling `$mustache->loadTemplate($template)->render($data);`
128 122
 	 *
129  
-	 * @see \Mustache\Mustache::loadTemplate
130  
-	 * @see \Mustache\Template::render
  123
+	 * @see Mustache_Mustache::loadTemplate
  124
+	 * @see Mustache_Template::render
131 125
 	 *
132 126
 	 * @param string $template
133 127
 	 * @param mixed  $data
@@ -159,9 +153,9 @@ public function getCharset() {
159 153
 	/**
160 154
 	 * Set the Mustache template Loader instance.
161 155
 	 *
162  
-	 * @param \Mustache\Loader $loader
  156
+	 * @param Mustache_Loader $loader
163 157
 	 */
164  
-	public function setLoader(Loader $loader) {
  158
+	public function setLoader(Mustache_Loader $loader) {
165 159
 		$this->loader = $loader;
166 160
 	}
167 161
 
@@ -171,11 +165,11 @@ public function setLoader(Loader $loader) {
171 165
 	 * If no Loader instance has been explicitly specified, this method will instantiate and return
172 166
 	 * a StringLoader instance.
173 167
 	 *
174  
-	 * @return \Mustache\Loader
  168
+	 * @return Mustache_Loader
175 169
 	 */
176 170
 	public function getLoader() {
177 171
 		if (!isset($this->loader)) {
178  
-			$this->loader = new StringLoader;
  172
+			$this->loader = new Mustache_Loader_StringLoader;
179 173
 		}
180 174
 
181 175
 		return $this->loader;
@@ -184,9 +178,9 @@ public function getLoader() {
184 178
 	/**
185 179
 	 * Set the Mustache partials Loader instance.
186 180
 	 *
187  
-	 * @param \Mustache\Loader $partialsLoader
  181
+	 * @param Mustache_Loader $partialsLoader
188 182
 	 */
189  
-	public function setPartialsLoader(Loader $partialsLoader) {
  183
+	public function setPartialsLoader(Mustache_Loader $partialsLoader) {
190 184
 		$this->partialsLoader = $partialsLoader;
191 185
 	}
192 186
 
@@ -196,11 +190,11 @@ public function setPartialsLoader(Loader $partialsLoader) {
196 190
 	 * If no Loader instance has been explicitly specified, this method will instantiate and return
197 191
 	 * an ArrayLoader instance.
198 192
 	 *
199  
-	 * @return \Mustache\Loader
  193
+	 * @return Mustache_Loader
200 194
 	 */
201 195
 	public function getPartialsLoader() {
202 196
 		if (!isset($this->partialsLoader)) {
203  
-			$this->partialsLoader = new ArrayLoader;
  197
+			$this->partialsLoader = new Mustache_Loader_ArrayLoader;
204 198
 		}
205 199
 
206 200
 		return $this->partialsLoader;
@@ -209,14 +203,14 @@ public function getPartialsLoader() {
209 203
 	/**
210 204
 	 * Set partials for the current partials Loader instance.
211 205
 	 *
212  
-	 * @throws \RuntimeException If the current Loader instance is immutable
  206
+	 * @throws RuntimeException If the current Loader instance is immutable
213 207
 	 *
214 208
 	 * @param array $partials (default: array())
215 209
 	 */
216 210
 	public function setPartials(array $partials = array()) {
217 211
 		$loader = $this->getPartialsLoader();
218  
-		if (!$loader instanceof MutableLoader) {
219  
-			throw new \RuntimeException('Unable to set partials on an immutable Mustache Loader instance');
  212
+		if (!$loader instanceof Mustache_Loader_MutableLoader) {
  213
+			throw new RuntimeException('Unable to set partials on an immutable Mustache Loader instance');
220 214
 		}
221 215
 
222 216
 		$loader->setTemplates($partials);
@@ -229,13 +223,13 @@ public function setPartials(array $partials = array()) {
229 223
 	 * any other valid Mustache context value. They will be prepended to the context stack, so they will be available in
230 224
 	 * any template loaded by this Mustache instance.
231 225
 	 *
232  
-	 * @throws \InvalidArgumentException if $helpers is not an array or \Traversable
  226
+	 * @throws InvalidArgumentException if $helpers is not an array or Traversable
233 227
 	 *
234 228
 	 * @param array|Traversable $helpers
235 229
 	 */
236 230
 	public function setHelpers($helpers) {
237  
-		if (!is_array($helpers) && !$helpers instanceof \Traversable) {
238  
-			throw new \InvalidArgumentException('setHelpers expects an array of helpers');
  231
+		if (!is_array($helpers) && !$helpers instanceof Traversable) {
  232
+			throw new InvalidArgumentException('setHelpers expects an array of helpers');
239 233
 		}
240 234
 
241 235
 		$this->getHelpers()->clear();
@@ -248,13 +242,13 @@ public function setHelpers($helpers) {
248 242
 	/**
249 243
 	 * Get the current set of Mustache helpers.
250 244
 	 *
251  
-	 * @see \Mustache\Mustache::setHelpers
  245
+	 * @see Mustache_Mustache::setHelpers
252 246
 	 *
253  
-	 * @return \Mustache\HelperCollection
  247
+	 * @return Mustache_HelperCollection
254 248
 	 */
255 249
 	public function getHelpers() {
256 250
 		if (!isset($this->helpers)) {
257  
-			$this->helpers = new HelperCollection;
  251
+			$this->helpers = new Mustache_HelperCollection;
258 252
 		}
259 253
 
260 254
 		return $this->helpers;
@@ -263,7 +257,7 @@ public function getHelpers() {
263 257
 	/**
264 258
 	 * Add a new Mustache helper.
265 259
 	 *
266  
-	 * @see \Mustache\Mustache::setHelpers
  260
+	 * @see Mustache_Mustache::setHelpers
267 261
 	 *
268 262
 	 * @param string $name
269 263
 	 * @param mixed  $helper
@@ -275,7 +269,7 @@ public function addHelper($name, $helper) {
275 269
 	/**
276 270
 	 * Get a Mustache helper by name.
277 271
 	 *
278  
-	 * @see \Mustache\Mustache::setHelpers
  272
+	 * @see Mustache_Mustache::setHelpers
279 273
 	 *
280 274
 	 * @param string $name
281 275
 	 *
@@ -288,7 +282,7 @@ public function getHelper($name) {
288 282
 	/**
289 283
 	 * Check whether this Mustache instance has a helper.
290 284
 	 *
291  
-	 * @see \Mustache\Mustache::setHelpers
  285
+	 * @see Mustache_Mustache::setHelpers
292 286
 	 *
293 287
 	 * @param string $name
294 288
 	 *
@@ -301,7 +295,7 @@ public function hasHelper($name) {
301 295
 	/**
302 296
 	 * Remove a helper by name.
303 297
 	 *
304  
-	 * @see \Mustache\Mustache::setHelpers
  298
+	 * @see Mustache_Mustache::setHelpers
305 299
 	 *
306 300
 	 * @param string $name
307 301
 	 */
@@ -312,9 +306,9 @@ public function removeHelper($name) {
312 306
 	/**
313 307
 	 * Set the Mustache Tokenizer instance.
314 308
 	 *
315  
-	 * @param \Mustache\Tokenizer $tokenizer
  309
+	 * @param Mustache_Tokenizer $tokenizer
316 310
 	 */
317  
-	public function setTokenizer(Tokenizer $tokenizer) {
  311
+	public function setTokenizer(Mustache_Tokenizer $tokenizer) {
318 312
 		$this->tokenizer = $tokenizer;
319 313
 	}
320 314
 
@@ -323,11 +317,11 @@ public function setTokenizer(Tokenizer $tokenizer) {
323 317
 	 *
324 318
 	 * If no Tokenizer instance has been explicitly specified, this method will instantiate and return a new one.
325 319
 	 *
326  
-	 * @return \Mustache\Tokenizer
  320
+	 * @return Mustache_Tokenizer
327 321
 	 */
328 322
 	public function getTokenizer() {
329 323
 		if (!isset($this->tokenizer)) {
330  
-			$this->tokenizer = new Tokenizer;
  324
+			$this->tokenizer = new Mustache_Tokenizer;
331 325
 		}
332 326
 
333 327
 		return $this->tokenizer;
@@ -336,9 +330,9 @@ public function getTokenizer() {
336 330
 	/**
337 331
 	 * Set the Mustache Parser instance.
338 332
 	 *
339  
-	 * @param \Mustache\Parser $parser
  333
+	 * @param Mustache_Parser $parser
340 334
 	 */
341  
-	public function setParser(Parser $parser) {
  335
+	public function setParser(Mustache_Parser $parser) {
342 336
 		$this->parser = $parser;
343 337
 	}
344 338
 
@@ -347,11 +341,11 @@ public function setParser(Parser $parser) {
347 341
 	 *
348 342
 	 * If no Parser instance has been explicitly specified, this method will instantiate and return a new one.
349 343
 	 *
350  
-	 * @return \Mustache\Parser
  344
+	 * @return Mustache_Parser
351 345
 	 */
352 346
 	public function getParser() {
353 347
 		if (!isset($this->parser)) {
354  
-			$this->parser = new Parser;
  348
+			$this->parser = new Mustache_Parser;
355 349
 		}
356 350
 
357 351
 		return $this->parser;
@@ -360,9 +354,9 @@ public function getParser() {
360 354
 	/**
361 355
 	 * Set the Mustache Compiler instance.
362 356
 	 *
363  
-	 * @param \Mustache\Compiler $compiler
  357
+	 * @param Mustache_Compiler $compiler
364 358
 	 */
365  
-	public function setCompiler(Compiler $compiler) {
  359
+	public function setCompiler(Mustache_Compiler $compiler) {
366 360
 		$this->compiler = $compiler;
367 361
 	}
368 362
 
@@ -371,11 +365,11 @@ public function setCompiler(Compiler $compiler) {
371 365
 	 *
372 366
 	 * If no Compiler instance has been explicitly specified, this method will instantiate and return a new one.
373 367
 	 *
374  
-	 * @return \Mustache\Compiler
  368
+	 * @return Mustache_Compiler
375 369
 	 */
376 370
 	public function getCompiler() {
377 371
 		if (!isset($this->compiler)) {
378  
-			$this->compiler = new Compiler;
  372
+			$this->compiler = new Mustache_Compiler;
379 373
 		}
380 374
 
381 375
 		return $this->compiler;
@@ -403,7 +397,7 @@ public function getTemplateClassName($source) {
403 397
 	 *
404 398
 	 * @param string $name
405 399
 	 *
406  
-	 * @return \Mustache\Template
  400
+	 * @return Mustache_Template
407 401
 	 */
408 402
 	public function loadTemplate($name) {
409 403
 		return $this->loadSource($this->getLoader()->load($name));
@@ -417,7 +411,7 @@ public function loadTemplate($name) {
417 411
 	 *
418 412
 	 * @param string $name
419 413
 	 *
420  
-	 * @return \Mustache\Template
  414
+	 * @return Mustache_Template
421 415
 	 */
422 416
 	public function loadPartial($name) {
423 417
 		return $this->loadSource($this->getPartialsLoader()->load($name));
@@ -432,7 +426,7 @@ public function loadPartial($name) {
432 426
 	 * @param string $source
433 427
 	 * @param string $delims (default: null)
434 428
 	 *
435  
-	 * @return \Mustache\Template
  429
+	 * @return Mustache_Template
436 430
 	 */
437 431
 	public function loadLambda($source, $delims = null) {
438 432
 		if ($delims !== null) {
@@ -445,13 +439,13 @@ public function loadLambda($source, $delims = null) {
445 439
 	/**
446 440
 	 * Instantiate and return a Mustache Template instance by source.
447 441
 	 *
448  
-	 * @see \Mustache\Mustache::loadTemplate
449  
-	 * @see \Mustache\Mustache::loadPartial
450  
-	 * @see \Mustache\Mustache::loadLambda
  442
+	 * @see Mustache_Mustache::loadTemplate
  443
+	 * @see Mustache_Mustache::loadPartial
  444
+	 * @see Mustache_Mustache::loadLambda
451 445
 	 *
452 446
 	 * @param string $source
453 447
 	 *
454  
-	 * @return \Mustache\Template
  448
+	 * @return Mustache_Template
455 449
 	 */
456 450
 	private function loadSource($source) {
457 451
 		$className = $this->getTemplateClassName($source);
@@ -478,7 +472,7 @@ private function loadSource($source) {
478 472
 	/**
479 473
 	 * Helper method to tokenize a Mustache template.
480 474
 	 *
481  
-	 * @see \Mustache\Tokenizer::scan
  475
+	 * @see Mustache_Tokenizer::scan
482 476
 	 *
483 477
 	 * @param string $source
484 478
 	 *
@@ -491,7 +485,7 @@ private function tokenize($source) {
491 485
 	/**
492 486
 	 * Helper method to parse a Mustache template.
493 487
 	 *
494  
-	 * @see \Mustache\Parser::parse
  488
+	 * @see Mustache_Parser::parse
495 489
 	 *
496 490
 	 * @param string $source
497 491
 	 *
@@ -504,7 +498,7 @@ private function parse($source) {
504 498
 	/**
505 499
 	 * Helper method to compile a Mustache template.
506 500
 	 *
507  
-	 * @see \Mustache\Compiler::compile
  501
+	 * @see Mustache_Compiler::compile
508 502
 	 *
509 503
 	 * @param string $source
510 504
 	 *
@@ -533,7 +527,7 @@ private function getCacheFilename($source) {
533 527
 	/**
534 528
 	 * Helper method to dump a generated Mustache Template subclass to the file cache.
535 529
 	 *
536  
-	 * @throws \RuntimeException if unable to write to $fileName.
  530
+	 * @throws RuntimeException if unable to write to $fileName.
537 531
 	 *
538 532
 	 * @param string $fileName
539 533
 	 * @param string $source
@@ -552,6 +546,6 @@ private function writeCacheFile($fileName, $source) {
552 546
 			}
553 547
 		}
554 548
 
555  
-		throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $fileName));
  549
+		throw new RuntimeException(sprintf('Failed to write cache file "%s".', $fileName));
556 550
 	}
557 551
 }
32  src/Mustache/Parser.php
@@ -9,14 +9,12 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14 12
 /**
15 13
  * Mustache Parser class.
16 14
  *
17 15
  * This class is responsible for turning a set of Mustache tokens into a parse tree.
18 16
  */
19  
-class Parser {
  17
+class Mustache_Parser {
20 18
 
21 19
 	/**
22 20
 	 * Process an array of Mustache tokens and convert them into a parse tree.
@@ -26,20 +24,20 @@ class Parser {
26 24
 	 * @return array Mustache token parse tree
27 25
 	 */
28 26
 	public function parse(array $tokens = array()) {
29  
-		return $this->buildTree(new \ArrayIterator($tokens));
  27
+		return $this->buildTree(new ArrayIterator($tokens));
30 28
 	}
31 29
 
32 30
 	/**
33 31
 	 * Helper method for recursively building a parse tree.
34 32
 	 *
35  
-	 * @throws \LogicException when nesting errors or mismatched section tags are encountered.
  33
+	 * @throws LogicException when nesting errors or mismatched section tags are encountered.
36 34
 	 *
37  
-	 * @param \ArrayIterator $tokens Stream of Mustache tokens
  35
+	 * @param ArrayIterator $tokens Stream of Mustache tokens
38 36
 	 * @param array          $parent Parent token (default: null)
39 37
 	 *
40 38
 	 * @return array Mustache Token parse tree
41 39
 	 */
42  
-	private function buildTree(\ArrayIterator $tokens, array $parent = null) {
  40
+	private function buildTree(ArrayIterator $tokens, array $parent = null) {
43 41
 		$nodes = array();
44 42
 
45 43
 		do {
@@ -49,23 +47,23 @@ private function buildTree(\ArrayIterator $tokens, array $parent = null) {
49 47
 			if ($token === null) {
50 48
 				continue;
51 49
 			} elseif (is_array($token)) {
52  
-				switch ($token[Tokenizer::TYPE]) {
53  
-					case Tokenizer::T_SECTION:
54  
-					case Tokenizer::T_INVERTED:
  50
+				switch ($token[Mustache_Tokenizer::TYPE]) {
  51
+					case Mustache_Tokenizer::T_SECTION:
  52
+					case Mustache_Tokenizer::T_INVERTED:
55 53
 						$nodes[] = $this->buildTree($tokens, $token);
56 54
 						break;
57 55
 
58  
-					case Tokenizer::T_END_SECTION:
  56
+					case Mustache_Tokenizer::T_END_SECTION:
59 57
 						if (!isset($parent)) {
60  
-							throw new \LogicException('Unexpected closing tag: /'. $token[Tokenizer::NAME]);
  58
+							throw new LogicException('Unexpected closing tag: /'. $token[Mustache_Tokenizer::NAME]);
61 59
 						}
62 60
 
63  
-						if ($token[Tokenizer::NAME] !== $parent[Tokenizer::NAME]) {
64  
-							throw new \LogicException('Nesting error: ' . $parent[Tokenizer::NAME] . ' vs. ' . $token[Tokenizer::NAME]);
  61
+						if ($token[Mustache_Tokenizer::NAME] !== $parent[Mustache_Tokenizer::NAME]) {
  62
+							throw new LogicException('Nesting error: ' . $parent[Mustache_Tokenizer::NAME] . ' vs. ' . $token[Mustache_Tokenizer::NAME]);
65 63
 						}
66 64
 
67  
-						$parent[Tokenizer::END]   = $token[Tokenizer::INDEX];
68  
-						$parent[Tokenizer::NODES] = $nodes;
  65
+						$parent[Mustache_Tokenizer::END]   = $token[Mustache_Tokenizer::INDEX];
  66
+						$parent[Mustache_Tokenizer::NODES] = $nodes;
69 67
 
70 68
 						return $parent;
71 69
 						break;
@@ -81,7 +79,7 @@ private function buildTree(\ArrayIterator $tokens, array $parent = null) {
81 79
 		} while ($tokens->valid());
82 80
 
83 81
 		if (isset($parent)) {
84  
-			throw new \LogicException('Missing closing tag: ' . $parent[Tokenizer::NAME]);
  82
+			throw new LogicException('Missing closing tag: ' . $parent[Mustache_Tokenizer::NAME]);
85 83
 		}
86 84
 
87 85
 		return $nodes;
24  src/Mustache/Template.php
@@ -9,37 +9,35 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14 12
 /**
15 13
  * Abstract Mustache Template class.
16 14
  *
17 15
  * @abstract
18 16
  */
19  
-abstract class Template {
  17
+abstract class Mustache_Template {
20 18
 
21 19
 	/**
22  
-	 * @var \Mustache\Mustache
  20
+	 * @var Mustache_Mustache
23 21
 	 */
24 22
 	protected $mustache;
25 23
 
26 24
 	/**
27 25
 	 * Mustache Template constructor.
28 26
 	 *
29  
-	 * @param \Mustache\Mustache $mustache
  27
+	 * @param Mustache_Mustache $mustache
30 28
 	 */
31  
-	public function __construct(Mustache $mustache) {
  29
+	public function __construct(Mustache_Mustache $mustache) {
32 30
 		$this->mustache = $mustache;
33 31
 	}
34 32
 
35 33
 	/**
36 34
 	 * Mustache Template instances can be treated as a function and rendered by simply calling them:
37 35
 	 *
38  
-	 *     $m = new Mustache;
  36
+	 *     $m = new Mustache_Mustache;
39 37
 	 *     $tpl = $m->loadTemplate('Hello, {{ name }}!');
40 38
 	 *     echo $tpl(array('name' => 'World')); // "Hello, World!"
41 39
 	 *
42  
-	 * @see \Mustache\Template::render
  40
+	 * @see Mustache_Template::render
43 41
 	 *
44 42
 	 * @param mixed $context Array or object rendering context (default: array())
45 43
 	 *
@@ -67,11 +65,11 @@ public function render($context = array()) {
67 65
 	 *
68 66
 	 * @abstract
69 67
 	 *
70  
-	 * @param \Mustache\Context $context
  68
+	 * @param Mustache_Context $context
71 69
 	 *
72 70
 	 * @return string Rendered template
73 71
 	 */
74  
-	abstract public function renderInternal(Context $context, $indent = '', $escape = false);
  72
+	abstract public function renderInternal(Mustache_Context $context, $indent = '', $escape = false);
75 73
 
76 74
 	/**
77 75
 	 * Tests whether a value should be iterated over (e.g. in a section context).
@@ -104,7 +102,7 @@ public function render($context = array()) {
104 102
 	 */
105 103
 	protected function isIterable($value) {
106 104
 		if (is_object($value)) {
107  
-			return $value instanceof \Traversable;
  105
+			return $value instanceof Traversable;
108 106
 		} elseif (is_array($value)) {
109 107
 			$i = 0;
110 108
 			foreach ($value as $k => $v) {
@@ -126,10 +124,10 @@ protected function isIterable($value) {
126 124
 	 *
127 125
 	 * @param mixed $context Optional first context frame (default: null)
128 126
 	 *
129  
-	 * @return \Mustache\Context
  127
+	 * @return Mustache_Context
130 128
 	 */
131 129
 	protected function prepareContextStack($context = null) {
132  
-		$stack = new Context;
  130
+		$stack = new Mustache_Context;
133 131
 
134 132
 		$helpers = $this->mustache->getHelpers();
135 133
 		if (!$helpers->isEmpty()) {
4  src/Mustache/Tokenizer.php
@@ -9,14 +9,12 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache;
13  
-
14 12
 /**
15 13
  * Mustache Tokenizer class.
16 14
  *
17 15
  * This class is responsible for turning raw template source into a set of Mustache tokens.
18 16
  */
19  
-class Tokenizer {
  17
+class Mustache_Tokenizer {
20 18
 
21 19
 	// Finite state machine states
22 20
 	const IN_TEXT     = 0;
18  test/Mustache/Test/AutoloaderTest.php
@@ -9,29 +9,25 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache\Test;
13  
-
14  
-use Mustache\Autoloader;
15  
-
16 12
 /**
17 13
  * @group unit
18 14
  */
19  
-class AutoloaderTest extends \PHPUnit_Framework_TestCase {
  15
+class Mustache_Test_AutoloaderTest extends PHPUnit_Framework_TestCase {
20 16
 	public function testRegister() {
21  
-		$loader = Autoloader::register();
  17
+		$loader = Mustache_Autoloader::register();
22 18
 		$this->assertTrue(spl_autoload_unregister(array($loader, 'autoload')));
23 19
 	}
24 20
 
25 21
 	public function testAutoloader() {
26  
-		$loader = new Autoloader(__DIR__.'/../../fixtures/autoloader');
  22
+		$loader = new Mustache_Autoloader(dirname(__FILE__).'/../../fixtures/autoloader');
27 23
 
28 24
 		$this->assertNull($loader->autoload('NonMustacheClass'));
29 25
 		$this->assertFalse(class_exists('NonMustacheClass'));
30 26
 
31  
-		$loader->autoload('Mustache\Foo');
32  
-		$this->assertTrue(class_exists('Mustache\Foo'));
  27
+		$loader->autoload('Mustache_Foo');
  28
+		$this->assertTrue(class_exists('Mustache_Foo'));
33 29
 
34  
-		$loader->autoload('\Mustache\Bar');
35  
-		$this->assertTrue(class_exists('Mustache\Bar'));
  30
+		$loader->autoload('\Mustache_Bar');
  31
+		$this->assertTrue(class_exists('Mustache_Bar'));
36 32
 	}
37 33
 }
29  test/Mustache/Test/CompilerTest.php
@@ -9,21 +9,16 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-namespace Mustache\Test;
13  
-
14  
-use Mustache\Compiler;