Problem/Motivation
This causes a full 500 Service unavailable and makes the site unusable. The following log entries appear:
Type: php
Message: Twig\Error\SyntaxError: Unexpected token "operator" of value "-" ("end of statement block" expected). in Twig\TokenStream->expect() (line 33 of themes/contrib/radix/components/views-view/views-view.twig).
Severity: Error Steps to reproduce
Composer to install clean Drupal 10.1.6.
Enable required components (Single Directory Components, Serialization)
Composer to install Radix: composer require 'drupal/radix:^6.0@beta'
Enable the theme and set to default.
Happy to debug on my site if someone wants to lend some guidance on what is needed.
Remaining work
Apply same changes to navbar-brand.twig
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3404475.png | 446.5 KB | sandeepsingh199 |
| #4 | issue-3404475-twigerrorsyntaxerror-unexpected-token-fixes.patch | 704 bytes | viren18febs |
Issue fork radix-3404475
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Gorf commentedComment #4
viren18febs commentedI have fixed the above issue & added patch, please review.
Comment #5
sandeepsingh199 commented@viren18febS, I reviewed #4 patch and its throwing other issue.
Comment #6
boinkster commentedGetting a similar error, but occuring on form-element.twig:
Twig\Error\SyntaxError: Unexpected token "operator" of value "-" ("end of statement block" expected). in Twig\TokenStream->expect() (line 49 of themes/contrib/radix/components/form-element/form-element.twig).Following the fix in issue (https://www.drupal.org/project/radix/issues/3402732), in form-element.twig, I tried changing lines 49 and 63 to eliminate the "-". Tried both 'utility_classes' and 'form_element_utility_classes' for 'form-element_utility_classes', it then throws this:
TypeError: Unsupported operand types: null - array in __TwigTemplate_f15449672b5fa3b309636f75db5b3a19->doDisplay() (line 47 of /var/www/html/vendor/twig/twig/src/Environment.php(361) : eval()'d code).Comment #7
anicotoI got the same errors on views_view and navbar_branding, applying the same logic solved my issue.
Use
{% set utility_classes = utility_classes|join(' ') %}
Instead of
{% set navbar-brand_utility_classes = navbar-brand_utility_classes|join(' ') %}
Comment #8
anicotoAdding some remaining-work/next steps
Comment #9
anicotoAdding tags
Comment #10
amstercadFolks following this particular issue are advised to pay attention to this, (currently closed), issue as well: https://www.drupal.org/project/radix/issues/3402732, because everything seems related. Between us, we'll figure things out.
Comment #11
boinkster commentedWorking though templates with the fix suggested in #7, eventually leads to:
TypeError: Unsupported operand types: null - array in __TwigTemplate_7c900ea4bd68698dd0a963aeeff08683->doDisplay() (line 47 of /var/www/html/vendor/twig/twig/src/Environment.php(361) : eval()'d code).Comment #12
anicotoYou need to remove every navbar-brand_ in utility_classes
Comment #13
boinkster commentedStill throws the same error after changing every navbar-brand_utility_classes to utility_classes in navbar-brand.twig
Comment #14
doxigo commentedThis is becoming a mess with the
utility_classes, I have two options:1. Make every utility class of every component named just:
utility_classes2. What we have at the moment (but fix the problem) and name:
[component-name]_utility_classesI wonder if the first option makes more sense here, any pros and cons worth sharing, love to hear what you guys think
Comment #15
boinkster commentedI'm new to SDC so don't have knowledge of whether
utility_classeseverywhere would be an issue down the road.Comment #16
boinkster commentedIt's unclear to me what is happening with the twig
utility_classesternary statement and subsequentclassesmerge. How does a value get passed in toutility_classesand why would you need to?Comment #17
doxigo commentedOkay thank you all for helping out on this, it was a naming convention issue causing the breakdown. pushed a fix and tagged a new beta3 release.
crediting all
Comment #19
anicotoAwesome @doxigo thanks!
Comment #20
anicoto