【问题标题】:Is in smarty an equivalent for macros like in twig在 smarty 中相当于 twig 中的宏
【发布时间】:2013-03-16 11:44:05
【问题描述】:

我想知道在 smarty 中是否有来自 twig http://twig.sensiolabs.org/doc/tags/macro.html 的宏函数的等价物。

我不想为此使用 smarty 插件,因为我希望能够将这些宏直接写入模板。

我发现的唯一的东西是{block} http://www.smarty.net/docs/en/advanced.features.template.inheritance.tpl 的模板继承,但我也想传递参数。

有什么等价的吗?

在我的示例中,我想将其用于 html 表单和输入,例如

<input type="{$type}" name="{$name}" value="{$value} [...]>

{$type}{$name}{$value} 是参数

【问题讨论】:

    标签: php macros smarty twig template-engine


    【解决方案1】:

    是的,Smarty 3 有 {function} 标签,它就是这样做的:http://www.smarty.net/docs/en/language.function.function.tpl

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-11
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-29
      • 1970-01-01
      相关资源
      最近更新 更多