【发布时间】:2023-04-01 10:37:02
【问题描述】:
我有一个数组 ('db-titles'),它的项目是以 'TextA*TextB' 形式组成的字符串。
我想从这些数组项中创建以下 HTML 结构:<span>TextA</span><span>TextB</span>
为此,我使用以下流畅的脚本:
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<f:if condition="{db-titles -> f:count()} > 1">
<f:then>
<!-- This works as expected, the html code will be rendered correctly -->
<v:iterator.for from="0" to="{db-titles -> f:count()}" iteration="i">
<span><v:format.replace content="{db-titles.{i.index}}" substring="*" replacement="</span><span>"/></span>
</v:iterator.for>
</f:then>
<f:else>
<!-- This strangely does not work, although I - instead of running through all values of the array - just want to output the first value of it.... -->
<span><v:format.replace content="{v:iterator.first(haystack: db-titles)}" substring="*" replacement="</span><span>"/></span>
</f:else>
</f:if>
正如我在源代码中评论的那样,在“</span><span>)奇怪地呈现为文本而不是 HTML:<span>TextA&lt;/span&gt;&lt;span&gt;TextB</span>
这怎么可能?
让我提一下,我使用“PHPStorm”应用程序进行编程 - 程序是否有可能将源代码呈现错误?
提前感谢您的帮助!
【问题讨论】:
标签: typo3 fluid view-helpers