【问题标题】:Place line break at at every variable semicolon in smarty template在 smarty 模板中的每个变量分号处放置换行符
【发布时间】:2012-02-24 13:27:31
【问题描述】:

我有一个 smarty 模板,其中包含一个变量,其中数据作为一个文本字符串加载,但值用分号分隔。

<span>{$TEST.data}</span>

这会生成一行,例如:1;示例:2;示例:3;等等。

有没有办法可以在 smarty 中的每个分号处换行编码?

感谢您的帮助

【问题讨论】:

  • 不确定,但这在 PHP 中很容易:str_replace(";", ";&lt;br&gt;", $TEST-&gt;data);

标签: smarty


【解决方案1】:

虽然您实际上应该在 PHP 中准备数据,但您可以在 Smarty 中执行此操作:

{$test.data|replace:";":"<br>"}

请参阅replace modifier 上的文档

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-03
    • 2012-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-11
    相关资源
    最近更新 更多