Exemplo n.º 1
0
 /**
  * Creates the TST tree structure from the source code.
  *
  * @return void
  */
 public function parseIntoNodeTree()
 {
     if (!$this->source->hasCode()) {
         throw new ezcTemplateException(ezcTemplateSourceToTstErrorMessages::MSG_NO_SOURCE_CODE);
     }
     $sourceText = $this->source->code;
     $cursor = new ezcTemplateCursor($sourceText);
     $this->textElements = array();
     $parser = new ezcTemplateProgramSourceToTstParser($this, null, null);
     $parser->setAllCursors($cursor);
     if (!$parser->parse()) {
         $currentParser = $parser->getFailingParser();
     }
     // Trim starting/trailing whitespace
     if ($this->trimWhitespace) {
         $this->whitespaceRemoval->trimProgram($parser->program);
     }
     return $parser->program;
 }
Exemplo n.º 2
0
 /**
  * Test hasCode() with no code
  */
 public function testHasNoCode()
 {
     $src = new ezcTemplateSourceCode($this->templatePath . "zhadum.ezt", "planet:zhadum.ezt", false);
     self::assertSame($this->templatePath . "zhadum.ezt", $src->stream, 'Property <stream> does not return correct value.');
     self::assertSame("planet:zhadum.ezt", $src->resource, 'Property <resource> does not return correct value.');
     self::assertSame(false, $src->code, 'Property <code> does not return correct value.');
     //        self::assertSame( null, $src->context, 'Property <context> does not return correct value.' );
     self::assertSame(false, $src->hasCode(), 'Method hasCode() does not return false.');
 }