dongyanggan3025 2011-07-07 10:42
浏览 24
已采纳

如何将Mustache与Symfony集成?

I'd like to replace default template of symfony1.4 with Mustache. To my surprise, I cannot find related approach by Google search.

Then, I suppose I can do it in simple way.

public function executeIndex(sfWebRequest $request)
{
include('/path/to/Mustache.php');
   $m = new Mustache();
   echo $m->render('Hello {{planet}}', array('planet' => 'World!'));

   return sfView::NONE;
}

This looks clumsy. The main problems are:

Where to store the mustache template('Hello {{planet}}' in my case)?

Is it possible to replace default View Handler? so that I can put mustache template in templates folder and be transparent to action?

Thanks

  • 写回答

2条回答 默认 最新

  • drxm72811 2011-07-07 10:46
    关注

    I think the best way to implement it, is to create a new sfView implementation. Currently the sfPhpView is the default class for rendering the output. You could extend this class, and use Mustache for the rendering.

    You could take a look sfSmartyPlugin to see how they have implemented the Smarty Template Engine...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用S7-200 SIM 2.0,导入程序时出现了这个问题(关键词-子程序)
  • ¥15 pip安装pystan显示No module named 'Cython'的问题
  • ¥15 Fortran代码segment fault
  • ¥15 求一下解题思路,需完整的步骤和代码。
  • ¥15 苹果CMS搭建的视频网站首页打开为什么会自动跳转到色情页面?
  • ¥15 php,mysql的问题
  • ¥50 dac adc的检定规程
  • ¥20 MIT控制器能控制不稳定系统吗
  • ¥15 公司代码X对业务伙伴X无效,处理方法?
  • ¥15 微信内链接跳转到浏览器打开怎么实现