Unknown drupal_view() function although Twig Tweak is installed
-
26-02-2021 - |
문제
Acquia BLT won't let me commit some Twig.
> tests:twig:lint:all
Validating twig syntax for all custom modules and themes...
Iterating over fileset files.twig...
ERROR in ~/repos/agency/client-site/docroot/themes/custom/client_theme/templates/taxonomy/taxonomy-term--faq.html.twig (line 35)
33 {{ title_suffix }}
34 <div class="accordion" data-accordion>
>> 35 {{ drupal_view('faqs_per_term', 'block_1', term.id) }}
>> Unknown "drupal_view" function.
36 </div>
37 </div>
[WARNING] 28 Twig files have valid syntax and 1 contain errors.
I have installed and enabled Twig Tweak module, and rebuilt cache.
Do you know of any reason why BLT might not know the module is installed?
Possibly relevant: I'm running Drupal and BLT under Lando. The error is triggered after git push
but I get the same result if I call lando blt tests:twig:lint:all
directly.
해결책
If a module defines new twig filters or functions, they need to be manually excluded from the blt linter. Per a comment in the BLT issue queue, you can make these exclusions in blt.yml like:
validate:
twig:
functions:
- drupal_block
- drupal_field
- drupal_view
- drupal_block
- drupal_region
- drupal_entity
- drupal_field
- drupal_menu
- drupal_form
- drupal_image
- drupal_token
- drupal_config
- drupal_title
- drupal_url
- drupal_link
- drupal_messages
- drupal_breadcrumb
This is also documented in the Overriding variables at runtime section of the blt docs (it's near the bottom of the section, under the tests: list item).
제휴하지 않습니다 drupal.stackexchange