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

Twig Linting doesn't recognize Drupal functions/filters/etc #737

Closed
dpagini opened this issue Dec 3, 2016 · 4 comments
Closed

Twig Linting doesn't recognize Drupal functions/filters/etc #737

dpagini opened this issue Dec 3, 2016 · 4 comments
Assignees
Labels
Bug Something isn't working

Comments

@dpagini
Copy link
Contributor

dpagini commented Dec 3, 2016

My system information:

  • Operating system type: OSX
  • Operating system version: 10.12.1
  • BLT version: 8.6.0-beta1

Output of blt doctor:

+--------------------------+---------------------------------------------------------------------------------+
| Check                    | Outcome                                                                         |
+--------------------------+---------------------------------------------------------------------------------+
| checkDocrootExists       | Found docroot.                                                                  |
| checkCoreExists          | Drupal core exists                                                              |
| checkSettingsFile        | BLT settings are included in settings file.                                     |
| checkLocalSettingsFile   | Found your local settings file.                                                 |
| checkLocalDrushFile      | Found your local drush settings file.                                           |
| checkUri                 | $options['uri'] is set.                                                         |
| checkUriResponse         | Received a response from site local.mysite.com.                       |
| checkFileSystem:%files   | Public files directory is writable.                                             |
| checkFileSystem:%private | Private files directory is not set.                                             |
| checkFileSystem:%temp    | Temporary files directory is writable.                                          |
| checkDbConnection        | Connected to database.                                                          |
| checkDrupalBootstrapped  | Bootstrapped Drupal via drush.                                                  |
| checkDrupalInstalled     | Drupal is installed.                                                            |
| checkCaching:page        | Drupal cache is disabled.                                                       |
| checkCaching:css         | CSS preprocessing is disabled.                                                  |
| checkCaching:js          | JS preprocessing is disabled.                                                   |
| checkNvmExists           | NVM does not exist.                                                             |
|                          |                                                                                 |
|                          | It is recommended that you use NVM to manage multiple versions of NodeJS on one |
|                          | machine.                                                                        |
|                          | Instructions for installing NVM can be found at:                                |
|                          |   https://github.com/creationix/nvm#installation                                |
| checkCiConfig            | Git remotes are set in project.yml.                                             |
| checkComposer:require    | acquia/blt is in composer.json's require object.                                |
| checkComposer:plugins    | hirak/prestissimo plugin for composer is installed.                             |
| checkBehat:exists        | Behat local settings file exists.                                               |
| checkProjectYml:keys     | project.yml has no deprecated keys.                                             |
| checkPhpDateTimezone     | PHP setting for date.timezone is correctly set                                  |
+--------------------------+---------------------------------------------------------------------------------+

When I run this command:

git commit -m "Some commit message"

I get the following output:

      11      */
      12     #}
  >>  13     <img{{ attributes|without('height','width') }} />
  >> Unknown "without" filter. 
      14     
  ERROR  in /Users/dpagini/Websites/mysite/docroot/themes/custom/mytheme/templates/layout/html.html.twig (line 27)

And I expected this to happen:
This is a valid Drupal twig filters, so they should be recognized as such.

Apologies if this was already reported, or even fixed, but I couldn't find another issue that reported the same thing. The twig linting does not recognize drupal twig function such as path() or filters such as without. My commit was still successful, so I think this is just for information for now, but for this to be useful, I dont want to see these types of errors, or else the output here will just be ignored.

@bobbygryzynger
Copy link
Contributor

I can also confirm I'm seeing this on 8.6.0-beta1.

@grasmash grasmash added the Bug Something isn't working label Dec 5, 2016
@grasmash
Copy link
Contributor

grasmash commented Dec 5, 2016

Yup. Gotta dig into this. Not quite sure how to tell Twig about Drupal's custom filters and functions.

grasmash added a commit to grasmash/bolt that referenced this issue Dec 5, 2016
@grasmash grasmash self-assigned this Dec 5, 2016
grasmash added a commit to grasmash/bolt that referenced this issue Dec 5, 2016
@brooke-heaton
Copy link
Contributor

Not sure if this is related, but I'm getting this error because I'm using twig_tweak:

  ERROR  in /Users/brookeheaton/Sites/naswa/docroot/themes/custom/naswa/templates/paragraph/paragraph--landing-teaser.html.twig (line 10)
      8              {% set nid = content.field_shortcut_url.0['#plain_text'] %}
      9              {% set slink = "node/" ~ nid %}
  >>  10             {% set stitle = drupal_field('title', 'node', nid) %}
  >> Unknown "drupal_field" function. 
      11     {% endif %}
      12     

@brooke-heaton
Copy link
Contributor

per ^^^

drupal_field is a twig_tweak function: https://www.drupal.org/docs/8/modules/twig-tweak/cheat-sheet-8x-2x

Do I need to override this somehow or is my build simply indefinitely broken?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants