darasion
V2EX  ›  问与答

smarty 的模板可不可以像 django 模板那样继承着使用?

  •  
  •   darasion · May 19, 2011 · 5827 views
    This topic created in 5655 days ago, the information mentioned may be changed or developed.
    如题。

    做项目想抛弃那个巨丑的框架页。 但是模板最好是能够继承,整个页面要有个架子,然后具体的页面继承这个架子。
    8 replies  •  1970-01-01 08:00:00 +08:00
    explon
    explon
    May 19, 2011
    1
    YII 可以
    darasion
    darasion
    OP
    May 19, 2011
    2
    @explon 囧。 是可以,但项目组的都不用。。大家都用smarty。
    holystrike
    holystrike
    May 19, 2011 via iPhone
    3
    smarty3好像可以
    chuck911
    chuck911
    May 20, 2011
    4
    @explon 终于在v2ex上听说有人用Yii了
    @darasion 你要的是这个吗 http://www.smarty.net/inheritance
    Paranoid
    Paranoid
    May 20, 2011
    5
    哥也在用Yii :)~
    darasion
    darasion
    OP
    May 20, 2011
    6
    嗯嗯。
    项目组内的用yii和smary2.x,smarty3我看文档是有 继承,但是2却没有。

    所以想了个办法来模拟继承,
    在具体页面的上传入具体页面的模板:
    $smarty->assgin('content', 'index');
    $smarty->assgin('content', 'detail');
    ....

    然后每次都 display 架子 parent.html :
    。。。。
    {include file="$content.html"}

    。。。
    yesmeck
    yesmeck
    May 20, 2011
    7
    twig可以
    reus
    reus
    May 24, 2011
    8
    同推荐Twig,完胜smarty
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4872 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 03:22 · PVG 11:22 · LAX 19:22 · JFK 22:22
    ♥ Do have faith in what you're doing.