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

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

Open
sharique opened this issue Mar 25, 2022 · 6 comments
Open
Labels
Enhancement A feature or feature request

Comments

@sharique
Copy link

sharique commented Mar 25, 2022

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 sharique added the Bug Something isn't working label Mar 25, 2022
@github-actions github-actions bot changed the title Twig tweak module filter are not recognized in validate:twig. DX-5099: Twig tweak module filter are not recognized in validate:twig. Mar 25, 2022
@sharique
Copy link
Author

sharique commented Mar 25, 2022

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

validate:
  twig:
    filters:
      - check_markup

@mikemadison13
Copy link
Contributor

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 mikemadison13 added Enhancement A feature or feature request Awaiting response Maintainer needs more info and removed Bug Something isn't working labels Mar 30, 2022
@sharique
Copy link
Author

Yes, agree, I should be enhancement.

@no-response no-response bot removed the Awaiting response Maintainer needs more info label Mar 31, 2022
@jedgar1mx
Copy link

jedgar1mx commented Jul 7, 2022

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

@jedgar1mx
Copy link

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
Copy link

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

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

No branches or pull requests

3 participants