Reputation: 422
I wrote a viewhelper with renderChildren()
... I get this error, which makes no sense to me:
Templating tags not properly nested. Expected:
Tx_Hplusinfo_ViewHelpers_RehaKatViewHelper; Actual:
Tx_hplusinfo_ViewHelpers_RehaKatViewHelper
Here is the template part which leads to this message:
<f:if condition="{demand.pageId}=={settings.sucheRehaPid}">
<h:rehaKat klinik="{entfernung.klinik}" demand="{demand}" as="kat">
<td><f:if condition="{kat.isStationaer}">✓</f:if></td>
<td><f:if condition="{kat.isAmbulant}">✓</f:if></td>
</h:rehaKat>
</f:if>
This is the viewhelper render function:
/**
*
* @param Tx_Hplusinfo_Domain_Model_Klinik $klinik
* @param Tx_Hplusinfo_Domain_Model_SearchDemand $demand
* @param string $as Iteration variable
* @return string
*/
public function render(Tx_Hplusinfo_Domain_Model_Klinik $klinik, Tx_Hplusinfo_Domain_Model_SearchDemand $demand, $as ) {
$isAmbulant = false;
$isStationaer = false;
foreach($klinik->getReha() as $klinikreha) {
foreach($demand->getRehas() as $demandreha) {
if($klinikreha->getReha()->getUid() == $demandreha) {
if(!$isStationaer)
$isStationaer = $klinikreha->getIsStationaer();
if(!$isAmbulant)
$isAmbulant = $klinikreha->getIsAmbulant();
break;
}
}
if ($isAmbulant && $isStationaer)
break;
}
$this->templateVariableContainer->add($as, array('isAmbulant'=>$isAmbulant, 'isStationaer'=>$isStationaer));
return $this->renderChildren();
}
Upvotes: 1
Views: 2453
Reputation: 4261
Does this mean that closing tags are case sensitive, opening tags are not?
Since I like answers to be 100% complete I would like to add the explanation here. The reason for this is two parts: one, PHP class names are case insensitive (although class loaders may not be, depending on file system etc.) - and two, Fluid itself keeps track of the class name assigned to a ViewHelpers opening node that it matches the resolved class name of the closing node.
So what happens when a namespace declaration or ViewHelper reference is mistyped in terms of case is:
class_exists
is case insensitive on already loaded classes).So combine the triggers above and you can see that using a closing tag does mean Fluid behaves differently compared to using inline notation or self closing tags, and you can see how PHP class loading combined with Fluid behavior can in some edge cases result in this type of error occurring.
Upvotes: 1
Reputation: 422
Finally, I found the issue: It was a lower/upper misspelling of the namespace:
Wrong: {namespace h=Tx_hplusinfo_ViewHelpers}
Right: {namespace h=Tx_Hplusinfo_ViewHelpers}
(capital h)
The strange thing is that this misspelling was not an issue for the opening tag or any inline viewhelpers, e.g.
{h:myFormatter(inp:{xy})}
Does this mean that closing tags are case sensitive, opening tags are not?
Upvotes: 0