예제 #1
0
 public function generateCode(PHPTAL_Dom_Element $treeGen)
 {
     $codewriter = new PHPTAL_Php_CodeWriter($this->_state);
     $codewriter->doComment("\n*** DO NOT EDIT THIS FILE ***\n\nGenerated by PHPTAL from " . $this->_sourceFile . " (edit that file instead)");
     $codewriter->doFunction($this->_functionName, '$tpl, $ctx');
     $codewriter->setFunctionPrefix($this->_functionName . "_");
     $codewriter->doSetVar('$_thistpl', '$tpl');
     $codewriter->doSetVar('$_translator', '$tpl->getTranslator()');
     $treeGen->generateCode($codewriter);
     $codewriter->doEnd();
     return $codewriter->getResult();
 }
예제 #2
0
 public function generateCode(PHPTAL_Php_CodeWriter $codewriter)
 {
     // For backwards compatibility only!
     self::$_codewriter_bc_hack_ = $codewriter;
     // FIXME
     try {
         /// self-modifications
         if ($codewriter->getOutputMode() === PHPTAL::XHTML) {
             $this->replaceTextWithCDATA();
         }
         /// code generation
         if ($this->getSourceLine()) {
             $codewriter->doComment('tag "' . $this->qualifiedName . '" from line ' . $this->getSourceLine());
         }
         $this->generateSurroundHead($codewriter);
         if (count($this->replaceAttributes)) {
             foreach ($this->replaceAttributes as $att) {
                 $att->before($codewriter);
                 $att->after($codewriter);
             }
         } elseif (!$this->hidden) {
             // a surround tag may decide to hide us (tal:define for example)
             $this->generateHead($codewriter);
             $this->generateContent($codewriter);
             $this->generateFoot($codewriter);
         }
         $this->generateSurroundFoot($codewriter);
     } catch (PHPTAL_TemplateException $e) {
         $e->hintSrcPosition($this->getSourceFile(), $this->getSourceLine());
         throw $e;
     }
 }
예제 #3
0
 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     $codewriter->doComment($this->expression);
 }