diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 9227cad..d63c7a1 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -142,6 +142,10 @@ class Mustache_Engine public function __construct(array $options = array()) { if (isset($options['template_class_prefix'])) { + if ((string) $options['template_class_prefix'] === '') { + throw new Mustache_Exception_InvalidArgumentException('Mustache Constructor "template_class_prefix" must not be empty'); + } + $this->templateClassPrefix = $options['template_class_prefix']; } diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index ed06732..3e4d193 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -158,6 +158,16 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase $this->assertNotSame($mustache->getCache(), $mustache->getProtectedLambdaCache()); } + /** + * @expectedException Mustache_Exception_InvalidArgumentException + */ + public function testEmptyTemplatePrefixThrowsException() + { + new Mustache_Engine(array( + 'template_class_prefix' => '', + )); + } + /** * @expectedException Mustache_Exception_InvalidArgumentException * @dataProvider getBadEscapers