blt
blt copied to clipboard
DX-5099: Twig tweak module filter are not recognized in `validate:twig`.
Describe the bug
I'm using twig tweak module 3.1.3. Using one of the filter from it in a template and getting error on blt validate is giving error
To Reproduce Steps to reproduce the behavior, ideally starting from a fresh install of BLT:
- Run
composer require drupal/twig_tweak - Create/modify one of the templates in custom theme/module
- Use any tweak example
{{ '<b>bold</b> <strong>strong</strong>'|check_markup('restricted_html') }} - Run
blt validate - See the error.
Expected behavior Blt validate should not give any errror.
Detailed error output
Validating twig syntax for all custom modules and themes...
Iterating over fileset files.twig...
ERROR in /app/web/themes/custom/my_theme/templates/layout/region--footer.html.twig (line 26)
24 <div{{ attributes.addClass(classes) }}>
25 {{ content }}
>> 26 {{ '<b>bold</b> <strong>strong</strong>'|check_markup('restricted_html') }}
>> Unknown "check_markup" filter.
27 </div>
28 {% endif %}
[WARNING] 51 Twig files have valid syntax and 1 contain errors.
[error] Linting twig against fileset(s) files.twig returned a non-zero exit code.`
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/
System information
- Operating system type: Linux and WSL
- Operating system version: Fedora 35
- BLT version: 13.x
- PHP 8.0
One quick work around is to add skip filter option to blt.yml.
validate:
twig:
filters:
- check_markup
This doesn't feel like a bug to me, any additional (non-core, custom) twig filters need to be added to BLT for them to pass validation. i guess technically this could be a feature request to add all of the twig tweak filters to blt by default?
Yes, agree, I should be enhancement.
I also started to get issues with core filters like >> Unknown "attach_library" function. However, this is only on CI not locally.
It looks like the core TwigExtension.php file is not getting loaded correctly.
Warning: file_get_contents(/mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Core/Template/TwigExtension.php): Failed to open stream: No such file or directory in /mnt/tmp/local.prod/source/vendor/acquia/blt/src/Robo/Commands/Validate/TwigCommand.php on line 110
Looks like issue was cased by "allow-plugins" changes on composer. I needed to add acquia/blt to the allow-plugins section.
https://www.drupal.org/project/drupal/issues/3255749