Пример #1
0
 /**
  * @covers Cradle\Handlebars\HandlebarsException::forUnknownEnd
  */
 public function testForUnknownEnd()
 {
     $actual = null;
     try {
         throw HandlebarsException::forUnknownEnd('foo', 12);
     } catch (HandlebarsException $e) {
         $actual = $e->getMessage();
     }
     $expected = 'Unknown close tag: "foo" on line 12';
     $this->assertEquals($expected, $actual);
 }
Пример #2
0
 /**
  * Partially renders the section close tokens
  *
  * @param *array $node
  * @param *array $open
  *
  * @return string
  */
 protected function generateClose(array $node, array &$open)
 {
     $node['value'] = trim($node['value']);
     if ($this->findSection($open, $node['value']) === false) {
         throw HandlebarsException::forUnknownEnd($node['value'], $node['line']);
     }
     $buffer = '';
     $i = $this->findSection($open);
     if (!isset($open[$i]['else'])) {
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_5, -1);
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_6);
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_7);
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_FN_CLOSE);
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_EMPTY);
     } else {
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_BODY_5);
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_BODY_6);
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_BODY_7);
         $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_CLOSE, -1);
     }
     unset($open[$i]);
     $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_CLOSE, -1);
     $buffer .= $this->prettyPrint(self::BLOCK_ESCAPE_HELPER_CLOSE, -1);
     return $buffer;
 }