doubu4826 2014-04-10 12:40
浏览 48
已采纳

使用Twig和Slim在父模板中重复数组

I've just started using Slim and Twig and getting to grips with it all.

I am building a small site and will have a Twitter feed on every page. So, I want to put this in my layout template (base.html.twig). The only way I can see to do it is to pass it in to every route and then use an include that can access the details.

Seems like there must be a way to set it in the layout template once without passing it in through every route?

Any help or a related link would be great.

  • 写回答

1条回答 默认 最新

  • douhui5953 2014-04-10 13:18
    关注

    you can extend twig with user defined functions, just make a call inside template and you will not need for passing it every time http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部