【问题标题】:Make Smarty ignore white space up to the next statement让 Smarty 忽略空格直到下一条语句
【发布时间】:2012-02-26 16:15:10
【问题描述】:

在 Smarty 模板中,有没有办法让 Smarty 忽略具有大量缩进的逻辑结构化代码中的两个语句之间的空白,以便生成的 HTML 不包含它?一个实际的用法是避免两个链接之间的空白,因为链中的链接将根据它们之间是否存在空白而以不同的方式显示。我会这样想:

<a href="">A link</a>{ignore_whitespace_up_to_next_statement_please}
{if $var == "something"}{ignore_whitespace_up_to_next_statement_please}
  <a href="">Another link</a>
{/if}

这会产生这个 HTML 输出:

<a href="">A link</a><a href="">Another link</a>

【问题讨论】:

    标签: html smarty template-engine


    【解决方案1】:

    您可以使用{strip} 块。否则,我建议使用 outputfilter trimwhitespace(或它的派生词)。

    【讨论】:

      猜你喜欢
      • 2011-06-29
      • 2012-07-15
      • 2016-02-09
      • 1970-01-01
      • 2021-05-06
      • 2021-12-31
      • 1970-01-01
      • 2015-12-21
      • 1970-01-01
      相关资源
      最近更新 更多