00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 class PHPTAL_Attribute_TAL_Replace extends PHPTAL_Attribute
00024 {
00025 function
activate(&$g, &$tag)
00026 {
00027
if (preg_match('/\|\s*?\bdefault\b/sm', $this->expression)) {
00028 $g->doOBStart();
00029 foreach ($tag->_children as $child) {
00030 $err = $child->generateCode($g);
00031
if (PEAR::isError($err)) {
return $err; }
00032 }
00033 $g->doOBEnd('$__default__');
00034 $default =
true;
00035 }
00036 $g->setSource($tag->name(), $tag->line);
00037 $exp =
new PHPTAL_Expression($g, $tag, $this->expression);
00038 $exp->setPolicy(
_PHPTAL_ES_RECEIVER_IS_OUTPUT);
00039 $err = $exp->generate();
00040
if (PEAR::isError($err)) {
return $err; }
00041
00042
if (isset($
default)) { $g->execute('unset($__default__)'); }
00043 }
00044 };
00045
00046 ?>