大佬教程收集整理的这篇文章主要介绍了php-Twig_Error_Syntax:未知的“ template_from_string”函数.功能过时了吗?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我记得在作曲家更新后遇到了这个错误,但是以前它运行良好,并且在比较软件包版本时没有发现差异.我在模板中以这种方式使用它:
{{ include(template_from_string(page.body)) }}
其中“页面”是来自控制器的实体对象.当前版本是:
symfony/symfony v2.8.15
twig/extensions v1.4.1
twig/twig v1.30.0
twig:
debug: "%kernel.debug%"
Strict_variables: "%kernel.debug%"
form_themes:
- 'AppBundle::Form/form_override.html.twig'
现在在vendor / twig / twig / lib / twig / Twig / Extension / StringLoader.@L_675_3@中有视觉上正确的文件,但似乎仍然无法正常工作.完整的堆栈跟踪:
[1] Twig_Error_Syntax: UnkNown "template_from_string" function.
at n/a
in ProjectDir\src\AppBundle/resources/views/Page.html.twig line 22
at Twig_ExpressionParser->getFunctionNodeClass('template_from_string', '22')
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 374
at Twig_ExpressionParser->getFunctionNode('template_from_string', '22')
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 162
at Twig_ExpressionParser->parsePriMaryExpression()
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 102
at Twig_ExpressionParser->getPriMary()
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 55
at Twig_ExpressionParser->parseExpression()
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 520
at Twig_ExpressionParser->parseArguments(true)
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 373
at Twig_ExpressionParser->getFunctionNode('include', '22')
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 162
at Twig_ExpressionParser->parsePriMaryExpression()
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 102
at Twig_ExpressionParser->getPriMary()
in ProjectDir\vendor\twig\twig\lib\Twig\ExpressionParser.@L_675_3@ line 55
at Twig_ExpressionParser->parseExpression()
in ProjectDir\vendor\twig\twig\lib\Twig\Parser.@L_675_3@ line 147
at Twig_Parser->subparse(array(object(Twig_TokenParser_Block), 'decideBlockEnd'), truE)
in ProjectDir\vendor\twig\twig\lib\Twig\TokenParser\Block.@L_675_3@ line 40
at Twig_TokenParser_Block->parse(object(Twig_Token))
in ProjectDir\vendor\twig\twig\lib\Twig\Parser.@L_675_3@ line 190
at Twig_Parser->subparse(null, falsE)
in ProjectDir\vendor\twig\twig\lib\Twig\Parser.@L_675_3@ line 103
at Twig_Parser->parse(object(Twig_TokenStream))
in ProjectDir\app\cache\dev\classes.@L_675_3@ line 3415
at Twig_Environment->parse(object(Twig_TokenStream))
in ProjectDir\app\cache\dev\classes.@L_675_3@ line 3443
at Twig_Environment->compilesource(object(Twig_sourcE))
in ProjectDir\app\cache\dev\classes.@L_675_3@ line 3291
at Twig_Environment->loadTemplate('AppBundle::Page.html.twig')
in ProjectDir\vendor\symfony\symfony\src\Symfony\Bridge\Twig\TwigENGIne.@L_675_3@ line 126
at Symfony\Bridge\Twig\TwigENGIne->load('AppBundle::Page.html.twig')
in ProjectDir\vendor\symfony\symfony\src\Symfony\Bridge\Twig\TwigENGIne.@L_675_3@ line 50
at Symfony\Bridge\Twig\TwigENGIne->render('AppBundle::Page.html.twig', array('page' => object(PagE), 'ads' => array(object(VertBAnner), object(VertBAnner)), 'slug' => 'direktor'))
in ProjectDir\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\TwigENGIne.@L_675_3@ line 72
at Symfony\Bundle\TwigBundle\TwigENGIne->render('AppBundle::Page.html.twig', array('page' => object(PagE), 'ads' => array(object(VertBAnner), object(VertBAnner)), 'slug' => 'direktor'))
in ProjectDir\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\TwigENGIne.@L_675_3@ line 103
at Symfony\Bundle\TwigBundle\TwigENGIne->renderResponse('AppBundle::Page.html.twig', array('page' => object(PagE), 'ads' => array(object(VertBAnner), object(VertBAnner)), 'slug' => 'direktor'), null)
in ProjectDir\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller.@L_675_3@ line 185
at Symfony\Bundle\FrameworkBundle\Controller\Controller->render('AppBundle::Page.html.twig', array('page' => object(PagE), 'ads' => array(object(VertBAnner), object(VertBAnner)), 'slug' => 'direktor'))
in ProjectDir\src\AppBundle\Controller\PageController.@L_675_3@ line 35
at AppBundle\Controller\PageController->getPageAction('direktor')
in line
at call_user_func_array(array(object(PageController), 'getPageAction'), array('direktor'))
in ProjectDir\vendor\symfony\symfony\src\Symfony\Component\httpKernel\httpKernel.@L_675_3@ line 144
at Symfony\Component\httpKernel\httpKernel->handleRaw(object(request), '1')
in ProjectDir\vendor\symfony\symfony\src\Symfony\Component\httpKernel\httpKernel.@L_675_3@ line 64
at Symfony\Component\httpKernel\httpKernel->handle(object(request), '1', truE)
in ProjectDir\vendor\symfony\symfony\src\Symfony\Component\httpKernel\DependencyInjection\ContainerAwarehttpKernel.@L_675_3@ line 69
at Symfony\Component\httpKernel\DependencyInjection\ContainerAwarehttpKernel->handle(object(request), '1', truE)
in ProjectDir\vendor\symfony\symfony\src\Symfony\Component\httpKernel\Kernel.@L_675_3@ line 185
at Symfony\Component\httpKernel\Kernel->handle(object(request))
in ProjectDir\web\app_dev.@L_675_3@ line 28
at require('ProjectDir\web\app_dev.@L_675_3@')
in ProjectDir\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\resources\config\router_dev.@L_675_3@ line 40
解决方法:
您必须让服务容器知道您的Twig扩展:
# app/config/services.yml
acme.twig.extension.loader:
class: Twig_Extension_StringLoader
tags:
- { name: 'twig.extension' }
以上是大佬教程为你收集整理的php-Twig_Error_Syntax:未知的“ template_from_string”函数.功能过时了吗?全部内容,希望文章能够帮你解决php-Twig_Error_Syntax:未知的“ template_from_string”函数.功能过时了吗?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。