public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Type::check("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject); $aAttrs = $aObject->attributes(); $sType = strtolower($aAttrs->string('type')); if (in_array($sType, array('text/php', 'php'))) { foreach ($aObject->iterator() as $aChild) { if ($aChild instanceof AttributeValue) { continue; } $aDev->write(ExpressionCompiler::compileExpression($aChild->source(), $aObjectContainer->variableDeclares(), false, true)); } } else { if ($aAttrs->has('src') and !$aAttrs->bool('ignore')) { $sSrc = $aAttrs->get('src'); $aDev->preprocessStream()->write("\\org\\jecat\\framework\\resrc\\HtmlResourcePool::singleton()->addRequire({$sSrc},\\org\\jecat\\framework\\resrc\\HtmlResourcePool::RESRC_JS) ;"); // 清除后文中的空白字符 ClearCompiler::clearAfterWhitespace($aObject); } else { parent::compile($aObject, $aObjectContainer, $aDev, $aCompilerManager); } } }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); $aAttrs = $aObject->attributes(); if (!$aAttrs->has('rel')) { $aAttrs->set('rel', 'stylesheet'); } if ($aAttrs->has('src') and !$aAttrs->has('href')) { $aAttrs->set('href', $aAttrs->string('src')); } if (strtolower($aAttrs->string('rel')) == 'stylesheet' and !$aAttrs->bool('ignore')) { $sHref = $aAttrs->get('href'); $aDev->preprocessStream()->write("jc\\resrc\\HtmlResourcePool::singleton()->addRequire({$sHref},jc\\resrc\\HtmlResourcePool::RESRC_CSS) ;"); // 清除后文中的空白字符 ClearCompiler::clearAfterWhitespace($aObject); } else { $this->compileTag($aObject->headTag(), $aObjectContainer, $aDev, $aCompilerManager); $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); if ($aTailTag = $aObject->tailTag()) { $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); $this->compileTag($aTailTag, $aObjectContainer, $aDev, $aCompilerManager); } } }