blt icon indicating copy to clipboard operation
blt copied to clipboard

DX-5099: Twig tweak module filter are not recognized in `validate:twig`.

Open sharique opened this issue 3 years ago • 6 comments

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:

  1. Run composer require drupal/twig_tweak
  2. Create/modify one of the templates in custom theme/module
  3. Use any tweak example {{ '<b>bold</b> <strong>strong</strong>'|check_markup('restricted_html') }}
  4. Run blt validate
  5. 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

sharique avatar Mar 25 '22 11:03 sharique

One quick work around is to add skip filter option to blt.yml.

validate:
  twig:
    filters:
      - check_markup

sharique avatar Mar 25 '22 13:03 sharique

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?

mikemadison13 avatar Mar 30 '22 19:03 mikemadison13

Yes, agree, I should be enhancement.

sharique avatar Mar 31 '22 16:03 sharique

I also started to get issues with core filters like >> Unknown "attach_library" function. However, this is only on CI not locally.

jedgar1mx avatar Jul 07 '22 01:07 jedgar1mx

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

jedgar1mx avatar Jul 07 '22 02:07 jedgar1mx

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

jedgar1mx avatar Jul 11 '22 05:07 jedgar1mx