cakephp / twig-view

Twig View for CakePHP
MIT License
13 stars 6 forks source link

Unknown "getVars" function. #54

Closed kevindecapite closed 4 years ago

kevindecapite commented 4 years ago

With this in my Twig template:

{% do getVars()|debug %}

I get the following output when baking:

2020-06-10 21:46:47 Error: [Twig\Error\SyntaxError] Unknown "getVars" function. in /srv/app/plugins/ThemeCms/templates/bake/Template/index.twig on line 10
Stack Trace:
- /srv/app/vendor/twig/twig/src/ExpressionParser.php:446
- /srv/app/vendor/twig/twig/src/ExpressionParser.php:235
- /srv/app/vendor/twig/twig/src/ExpressionParser.php:175
- /srv/app/vendor/twig/twig/src/ExpressionParser.php:70
- /srv/app/vendor/twig/twig/src/TokenParser/DoTokenParser.php:25
- /srv/app/vendor/twig/twig/src/Parser.php:182
- /srv/app/vendor/twig/twig/src/Parser.php:95
- /srv/app/vendor/twig/twig/src/Environment.php:479
- /srv/app/vendor/twig/twig/src/Environment.php:507
- /srv/app/vendor/twig/twig/src/Environment.php:348
- /srv/app/vendor/twig/twig/src/Environment.php:309
- /srv/app/vendor/cakephp/twig-view/src/View/TwigView.php:297
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:1121
- /srv/app/vendor/cakephp/bake/src/View/BakeView.php:100
- /srv/app/vendor/cakephp/bake/src/Utility/TemplateRenderer.php:101
- /srv/app/vendor/cakephp/bake/src/Command/TemplateCommand.php:388
- /srv/app/vendor/cakephp/bake/src/Command/TemplateCommand.php:343
- /srv/app/vendor/cakephp/bake/src/Command/TemplateCommand.php:127
- /srv/app/vendor/cakephp/cakephp/src/Console/BaseCommand.php:175
- /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php:336
- /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php:171
- /srv/app/bin/cake.php:12

Versions:

Baking is working fine otherwise.

othercorey commented 4 years ago

getVars() isn't defined as the error says. If you're trying to access the View instance, you must use the global _view.

kevindecapite commented 4 years ago

So is that _view.getVars()? It's not clear from the readme which mentions the method.

othercorey commented 4 years ago

@kevindecapite Sorry for the confusion. Those wrapper functions were removed when we migrated from wyrihaximus/twig-view to cakephp/twig-view. Since they are simple functions, we're leaving them to the user to access via _view.

kevindecapite commented 4 years ago

@othercorey Makes sense. Thank you for the clarification!