Ejemplo n.º 1
0
 /**
  * @covers Cradle\Handlebars\HandlebarsHandler::registerPartial
  */
 public function testRegisterPartial()
 {
     //basic
     $template = $this->object->reset()->registerPartial('foo', 'This is {{ foo }}')->registerPartial('bar', 'Foo is not {{ bar }}')->compile('{{> foo }} ... {{> bar }}');
     $results = $template(['foo' => 'FOO', 'bar' => 'BAR']);
     $this->assertEquals('This is FOO ... Foo is not BAR', $results);
     //with scope
     $template = $this->object->reset()->registerPartial('foo', 'This is {{ foo }}')->registerPartial('bar', 'Foo is not {{ bar }}')->compile('{{> foo }} ... {{> bar zoo}}');
     $results = $template(['foo' => 'FOO', 'bar' => 'BAR', 'zoo' => ['bar' => 'ZOO']]);
     $this->assertEquals('This is FOO ... Foo is not ZOO', $results);
     //with attributes
     $template = $this->object->reset()->registerPartial('foo', 'This is {{ foo }}')->registerPartial('bar', 'Foo is not {{ something }}')->compile('{{> foo }} ... {{> bar zoo something="Amazing"}}');
     $results = $template(['foo' => 'FOO', 'bar' => 'BAR', 'zoo' => ['bar' => 'ZOO']]);
     $this->assertEquals('This is FOO ... Foo is not Amazing', $results);
 }