动态元素
Dynamic Elements
有没有办法像这样在流体中动态创建元素:
<f:section name="foo">
<{tag} />
</f:section>
像这样的地方应该使用什么:
<f:render section="foo" arguments="{ tag: 'f:form.textfield' }" />
输出结果应该是什么,包含:<input type="text" … />
,而不是 <f:form.textfield … />
。
不是那样,但你可以用 f:switch
:
做点什么
<f:section name="foo">
<f:switch expression={tag}>
<f:case value="f:form.textfield"><f:form.textfield /></f:case>
<f:case value="etc">...</f:case>
</f:switch>
</f:section>
有没有办法像这样在流体中动态创建元素:
<f:section name="foo">
<{tag} />
</f:section>
像这样的地方应该使用什么:
<f:render section="foo" arguments="{ tag: 'f:form.textfield' }" />
输出结果应该是什么,包含:<input type="text" … />
,而不是 <f:form.textfield … />
。
不是那样,但你可以用 f:switch
:
<f:section name="foo">
<f:switch expression={tag}>
<f:case value="f:form.textfield"><f:form.textfield /></f:case>
<f:case value="etc">...</f:case>
</f:switch>
</f:section>