duanchun1909 2013-03-16 11:44
浏览 59
已采纳

在smarty中等同于像树枝一样的宏

I've wondered if there is an equivalent for the macro function from twig http://twig.sensiolabs.org/doc/tags/macro.html in smarty.

I don't want to use smarty plugins for that because I want be able to write these macros right into the templates.

The only thing I found was the template inheritance with {block} http://www.smarty.net/docs/en/advanced.features.template.inheritance.tpl, but I want to pass arguments too.

Is there any equivalent for that?

In my example I want to use this for html forms and inputs like

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

{$type}, {$name}, and {$value} are the arguments

  • 写回答

1条回答 默认 最新

  • dr637349 2013-03-16 17:05
    关注

    Yep, Smarty 3 has the {function} tag which does exactly that: http://www.smarty.net/docs/en/language.function.function.tpl

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真