如何使用VHS ViewHelper v:replace解决一个奇怪的问题?

问题描述

我有一个数组(“ 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”进行编程-程序是否可能将源代码渲染为错误?

在此先感谢您的帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)