Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught Twig_Error_Syntax: Unexpected token "punctuation" of value "|" #63

Open
Petervw opened this issue Nov 25, 2018 · 3 comments

Comments

@Petervw
Copy link

Petervw commented Nov 25, 2018

Hi there,

First of all, thanks for your repository! Great trick to extract the translations from our twig files.

While we are updating our translation files, we encountered this error. Can you help with a fix?

Thanks,
Petervw


PHP Fatal error: Uncaught Twig_Error_Syntax: Unexpected token "punctuation" of value "|" ("name" expected)
....
in phar:///usr/local/bin/twig-gettext-extractor/vendor/twig/twig/lib/Twig/TokenStream.php:87

Stack trace:

#0 phar:///usr/local/bin/twig-gettext-extractor/vendor/twig/twig/lib/Twig/ExpressionParser.php(449): Twig_TokenStream->expect(5)
#1 phar:///usr/local/bin/twig-gettext-extractor/vendor/twig/twig/lib/Twig/ExpressionParser.php(443): Twig_ExpressionParser->parseFilterExpressionRaw(Object(Twig_Node_Expression_Constant))
#2 phar:///usr/local/bin/twig-gettext-extractor/vendor/twig/twig/lib/Twig/ExpressionParser.php(302): Twig_ExpressionParser->parseFilterExpression(Object(Twig_Node_Expression_Constant))
#3 phar:///usr/local/bin/twig-gettext-extractor/vendor/twig/twig/lib/Twig/ExpressionParser.php(194): Twig_ExpressionParser->parsePostfixExpression(Object(Twig_Node_Expression_Constant))
#4 phar:///usr/local/ in phar:///usr/local/bin/twig-gettext-extractor/vendor/twig/twig/lib/Twig/TokenStream.php on line 87

Code example (the pipes are on line 4):

    {% if form.api_key == '' || form.button_text == '' %}
        <div class="alert alert-info">
@umpirsky
Copy link
Owner

umpirsky commented Nov 26, 2018

Does it happens with:

    {% if form.api_key == '' or form.button_text == '' %}
        <div class="alert alert-info">

@Petervw
Copy link
Author

Petervw commented Nov 26, 2018

@umpirsky, yes your code example is a good workaround. Note that OR doesn't work.

What do you think of a || implementation? Twig supports this syntax.

@umpirsky
Copy link
Owner

It is a bug, sure, that's why I keep it open, we should fix it. Just wanted to know if there is a workaround. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants