예제 #1
0
 public function generateCode(PHPTAL_Php_CodeWriter $codewriter)
 {
     if ($codewriter->getOutputMode() === PHPTAL::HTML5) {
         $codewriter->setDocType('<!DOCTYPE html>');
     } else {
         $codewriter->setDocType($this->getValueEscaped());
     }
     $codewriter->doDoctype();
 }
예제 #2
0
 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     $macroname = strtr(trim($this->expression), '-', '_');
     if (!preg_match('/^[a-z0-9_]+$/i', $macroname)) {
         throw new PHPTAL_ParserException('Bad macro name "' . $macroname . '"', $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
     }
     if ($codewriter->functionExists($macroname)) {
         throw new PHPTAL_TemplateException("Macro {$macroname} is defined twice", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
     }
     $codewriter->doFunction($macroname, 'PHPTAL $_thistpl, PHPTAL $tpl');
     $codewriter->doSetVar('$tpl', 'clone $tpl');
     $codewriter->doSetVar('$ctx', '$tpl->getContext()');
     $codewriter->doInitTranslator();
     $codewriter->doXmlDeclaration(true);
     $codewriter->doDoctype(true);
 }