/** * @covers Cradle\Handlebars\HandlebarsData::pop */ public function testPop() { $instance = $this->object->push(array('comment1' => 'this is good', 'comment2' => 'this is great', 'comment3' => 'this is nice'))->push(array('comment4' => 'this is cool', 'comment5' => 'this is awesome', 'comment6' => 'this is epic'))->pop(); $this->assertInstanceOf('Cradle\\Handlebars\\HandlebarsData', $instance); $this->assertEquals('Hello World', $this->object->find('../product_title')); $this->assertEquals('this is good', $this->object->find('comment1')); $this->assertEquals('this is great', $this->object->find('../product_comments.comment2')); $this->assertEquals('Hello World', $this->object->find('./../product_title')); $this->assertEquals('this is good', $this->object->find('./comment1')); $this->assertEquals('this is great', $this->object->find('.././product_comments.comment2')); }
<?php //--> use Cradle\Handlebars\HandlebarsData as Data; use Cradle\Handlebars\HandlebarsRuntime as Runtime; return function ($data = array()) { $noop = function () { }; $context = $data = Data::i($data); $helper = Runtime::getHelpers($data); $buffer = ''; $buffer .= '<div class="product-fields">' . "\n"; $buffer .= ' <div class="form-group'; $buffer .= $helper['if']($data->find('errors.product_title'), array('name' => 'if', 'args' => 'if errors.product_title', 'hash' => array(), 'fn' => function ($context = null) use($noop, $data, &$helper) { if (is_array($context)) { $data->push($context); } $buffer = ''; $buffer .= ' has-error'; if (is_array($context)) { $data->pop(); } return $buffer; }, 'inverse' => $noop)); $buffer .= ' clearfix">' . "\n"; $buffer .= ' <label class="control-label">'; $buffer .= htmlspecialchars($data->find('_ \'Title\''), ENT_COMPAT, 'UTF-8'); $buffer .= '</label>' . "\n"; $buffer .= ' <div>' . "\n"; $buffer .= ' <input' . "\n"; $buffer .= ' type="text"' . "\n";