Only allow anonymous function or class-based callback for higher-order sections.

This commit is contained in:
Justin Hileman
2010-08-09 10:17:13 -04:00
parent 8709a3969d
commit 18bffdaea0
2 changed files with 25 additions and 24 deletions
+3 -21
View File
@@ -37,14 +37,6 @@ class MustacheHigherOrderSectionsTest extends PHPUnit_Framework_TestCase {
);
}
public function testFunctionSectionCallback() {
$this->foo->wrapper = 'make_my_logo_bigger';
$this->assertEquals(
sprintf('<h1>%s</h1>', $this->foo->name),
$this->foo->render('{{#wrapper}}{{name}}{{/wrapper}}')
);
}
public function testStaticSectionCallback() {
$this->foo->trimmer = array(get_class($this->foo), 'staticTrim');
$this->assertEquals($this->foo->name, $this->foo->render('{{#trimmer}} {{name}} {{/trimmer}}'));
@@ -56,13 +48,8 @@ class MustacheHigherOrderSectionsTest extends PHPUnit_Framework_TestCase {
public function testViewArraySectionCallback() {
$data = array(
'name' => 'Bob',
'wrap' => 'make_my_logo_bigger',
'trim' => array(get_class($this->foo), 'staticTrim'),
);
$this->assertEquals(
sprintf('<h1>%s</h1>', $data['name']),
$this->foo->render('{{#wrap}}{{name}}{{/wrap}}', $data)
);
$this->assertEquals($data['name'], $this->foo->render('{{#trim}} {{name}} {{/trim}}', $data));
}
@@ -73,13 +60,12 @@ class MustacheHigherOrderSectionsTest extends PHPUnit_Framework_TestCase {
}
$data = array(
'name' => 'Bob',
'wrap' => 'make_my_logo_bigger',
'anonywrap' => function($text) {
return array('[[%s]]', $text);
'wrap' => function($text) {
return sprintf('[[%s]]', $text);
}
);
$this->assertEquals(
sprintf('<h1>%s</h1>', $data['name']),
sprintf('[[%s]]', $data['name']),
$this->foo->render('{{#wrap}}{{name}}{{/wrap}}', $data)
);
}
@@ -124,10 +110,6 @@ class Foo extends Mustache {
}
}
function make_my_logo_bigger($text) {
return sprintf('<h1>%s</h1>', $text);
}
class Monster extends Mustache {
public $_template = '{{#title}}{{title}} {{/title}}{{name}}';
public $title;