简体   繁体   English

在Symfony 2.1中渲染树枝模板

[英]Render twig templates in Symfony 2.1

I am migrating my app to Symfony 2.1 but I'm facing a big error. 我正在将应用程序迁移到Symfony 2.1,但遇到一个大错误。 I've got a command which calls the templating service to render a twig template. 我有一个命令,该命令调用模板服务以渲染树枝模板。 The code +- is: 代码+-是:

 $content = $this->getContainer()->get('templating')->render('XBundle:Pdf:x.pdf.twig', array(
            'variablea' => '',
            'variableb' => ''
 ));

It was working without any problem in Symfony 2.0.X. 在Symfony 2.0.X中它可以正常工作。 But after migrating into Symfony 2.1, when that piece of code is called, an exception occurs: 但是在移植到Symfony 2.1之后,调用该段代码时,会发生异常:

Fatal error: Call to undefined method Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\TemplateLocator::isFresh() in /vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php on line 49 致命错误:调用第49行上/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php中未定义的方法Symfony \\ Bundle \\ FrameworkBundle \\ Templating \\ Loader \\ TemplateLocator :: isFresh()

I've reported that in symfony/asseticbundle tracker on github like 14 days ago and nobody answers, which makes me think that I am the problem here... ( https://github.com/symfony/AsseticBundle/issues/122 ) 我已经报告说在github上的symfony / asseticbundle跟踪器中,就像14天前一样,没有人回答,这让我认为我是这里的问题...( https://github.com/symfony/AsseticBundle/issues/122

What am I doing wrong? 我究竟做错了什么?

Thanks!! 谢谢!!

您是否清除了缓存( php app/console cache:clear )并重建了引导文件?

Here are a few suggestions: 这里有一些建议:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM