TYPO3 Fluid Tipp 1: Variablen erstellen


<!-- Assigning variables //-->

1) <f:variable name="myvar" value="Hardcoded value"/>

2) <f:variable name="myvar">Larger expressions or static code</f:variable>

3) {f:variable(name: 'myvar', value: 'Hardcoded value')}

4) {my:expensiveViewHelper() -> f:variable(name: 'myvar')}

 

Then makes expression to use in f:render and others:

 

<f:render partial="MyPartial" arguments="{myvar: myvar}"/>

 

Rather than having to do, for example:

 

<f:render partial="MyPartial" arguments="{myvar: '{my:expensiveViewHelper()}'}" />

 

Which is *particularly* useful to avoid escaping inline syntax quotes!

<!-- Assigning variables //-->

1) <f:variable name="myvar" value="Hardcoded value"/>
2) <f:variable name="myvar">Larger expressions or static code</f:variable>
3) {f:variable(name: 'myvar', value: 'Hardcoded value')}
4) {my:expensiveViewHelper() -> f:variable(name: 'myvar')}

Then makes expression to use in f:render and others:

<f:render partial="MyPartial" arguments="{myvar: myvar}"/>

Rather than having to do, for example:

<f:render partial="MyPartial" arguments="{myvar: '{my:expensiveViewHelper()}'}" />

Which is *particularly* useful to avoid escaping inline syntax quotes!

Es gibt mehrere Möglichkeiten, mit Fluid Variablen zu nutzen. Zum Beispiel kann man mehrfach verwendete ViewHelper-Aufrufe vermeiden oder man definiert Variablen, die man dann f:render mitgibt.

Hat dir der Artikel gefallen?

Werkraum News: