Skip to content

Commit

Permalink
test on fig:append
Browse files Browse the repository at this point in the history
  • Loading branch information
zzgab committed Aug 9, 2015
1 parent 67a1212 commit 8be4743
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/figdice/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,21 +625,21 @@ private function plugIntoSlots($input) {
$slotPos = strpos($result, $slot->getAnchorString());

if( isset($this->plugs[$slotName]) ) {
foreach ($this->plugs[$slotName] as $plugElement) {
/** @var ViewElementTag[] $plugsForSlot */
$plugsForSlot = $this->plugs[$slotName];

foreach ($plugsForSlot as $plugElement) {
$plugElement->clearAttribute($this->figNamespace . 'plug');

$plugRender = $plugElement->render();
if($plugRender === false) {
return false;
}

if($plugElement->hasAttribute($this->figNamespace . 'append')) {
if($plugElement->evaluate($plugElement->getAttribute($this->figNamespace . 'append'))) {
if (($plugElement->hasAttribute($this->figNamespace . 'append')) &&
($plugElement->evaluate($plugElement->getAttribute($this->figNamespace . 'append'))) ) {

$plugOutput .= $plugRender;
}
else {
$plugOutput = $plugRender;
}
}
else {
$plugOutput = $plugRender;
Expand Down Expand Up @@ -672,9 +672,6 @@ public function fetchData($name) {
return $this->callStackData[0];
}
if($name == '.') {
//TODO: Attention ce n'est pas le dernier de la pile,
//qu'il faut prendre, mais le contexte actuel !
//(gare aux boucles imbriqu�es).
return $this->callStackData[count($this->callStackData) - 1];
}
if($name == '..') {
Expand All @@ -683,17 +680,15 @@ public function fetchData($name) {
if(count($this->callStackData) - 2 < 0) {
return null;
}
//TODO: Attention ce n'est pas l'avant-dernier de la pile,
//qu'il faut prendre, mais le vrai parent du contexte actuel !
//(gare aux boucles imbriqu�es)

return $this->callStackData[count($this->callStackData) - 2];
}

$stackDepth = count($this->callStackData);
for($i = $stackDepth - 1; $i >= 0; --$i) {

//If the piece of data is actually an object, rather than an array,
//then try to apply a Get method on the name of the property ( la Java Bean).
//then try to apply a Get method on the name of the property (a la Java Bean).
//If the object does not expose such method, try to obtain the object's property directly.
if(is_object($this->callStackData[$i])) {
$getter = 'get' . strtoupper($name[0]) . substr($name, 1);
Expand Down
26 changes: 26 additions & 0 deletions test/FigXmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,32 @@ public function testFeedClassNotFoundException()
$this->assertTrue(false);
}


public function testPlugAppend()
{
$view = new View();
$templateString = <<<ENDTEMPLATE
<fig:template>
<slot fig:slot="myslot"/>
Hello
<plug fig:plug="myslot">World</plug>
Of
<plug fig:plug="myslot" fig:append="true">Wonder</plug>
</fig:template>
ENDTEMPLATE;

$view->loadString($templateString);

$check = <<<ENDCHECK
<plug>World</plug><plug>Wonder</plug>
Hello
Of
ENDCHECK;

$this->assertEquals(trim( $check ), trim($view->render()) );
}

}


Expand Down

0 comments on commit 8be4743

Please sign in to comment.