Add default pragma option to Mustache_Engine.
Pragmas specified in the Mustache_Engine constructor will be enabled in all templates, regardless of the presence of pragma tags in individual templates.
This commit is contained in:
@@ -36,6 +36,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase
|
||||
'escape' => 'strtoupper',
|
||||
'entity_flags' => ENT_QUOTES,
|
||||
'charset' => 'ISO-8859-1',
|
||||
'pragmas' => array(Mustache_Engine::PRAGMA_FILTERS),
|
||||
));
|
||||
|
||||
$this->assertSame($logger, $mustache->getLogger());
|
||||
@@ -50,6 +51,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase
|
||||
$this->assertTrue($mustache->hasHelper('bar'));
|
||||
$this->assertFalse($mustache->hasHelper('baz'));
|
||||
$this->assertInstanceOf('Mustache_Cache_FilesystemCache', $mustache->getCache());
|
||||
$this->assertEquals(array(Mustache_Engine::PRAGMA_FILTERS), $mustache->getPragmas());
|
||||
}
|
||||
|
||||
public static function getFoo()
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Mustache.php.
|
||||
*
|
||||
* (c) 2010-2014 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pragmas
|
||||
* @group functional
|
||||
*/
|
||||
class Mustache_Test_FiveThree_Functional_EngineTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider pragmaData
|
||||
*/
|
||||
public function testPragmasConstructorOption($pragmas, $helpers, $data, $tpl, $expect)
|
||||
{
|
||||
$mustache = new Mustache_Engine(array(
|
||||
'pragmas' => $pragmas,
|
||||
'helpers' => $helpers,
|
||||
));
|
||||
|
||||
$this->assertEquals($expect, $mustache->render($tpl, $data));
|
||||
}
|
||||
|
||||
public function pragmaData()
|
||||
{
|
||||
$helpers = array(
|
||||
'longdate' => function (\DateTime $value) {
|
||||
return $value->format('Y-m-d h:m:s');
|
||||
}
|
||||
);
|
||||
|
||||
$data = array(
|
||||
'date' => new DateTime('1/1/2000', new DateTimeZone('UTC')),
|
||||
);
|
||||
|
||||
$tpl = '{{ date | longdate }}';
|
||||
|
||||
return array(
|
||||
array(array(Mustache_Engine::PRAGMA_FILTERS), $helpers, $data, $tpl, '2000-01-01 12:01:00'),
|
||||
array(array(), $helpers, $data, $tpl, '' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user