emulsify-ds / emulsify-drupal

Drupal theme built with Storybook and Webpack
GNU General Public License v2.0
92 stars 42 forks source link

*.fliter.php in emulsify_ds #199

Closed t3kn0ph34r closed 3 years ago

t3kn0ph34r commented 3 years ago

emulsify version (see releases): https://github.com/emulsify-ds/emulsify-drupal/releases/tag/2.2.0

node version: v15.9.0

npm (or yarn) version: yarn 1.22.10

What you did: Created some filters for the team to use in the original emulsify theme. Then upgraded the theme to the latest release of emulsify_ds. Lots of errors as the filters are used heavily in the templates.

What happened: Placing *.filter.php in components/_twig-components/filters would have the filters available. In emulsify_ds, this does not work. in the ReadMe for patternengine-twig in emulsify_ds, it mentions placing it in source/_twig-components/filters, but this doesn’t work.

Reproduction repository (if necessary):

Problem description: Don't know where to place *filter.php files in emulsify_ds. Suggested solution: Is there a new location to add this functionality in emulsify_ds? If so, it should be added to the ReadMe.

evanmwillhite commented 3 years ago

The new version of emulsify-drupal uses Twig extensions very differently because of Storybook. Storybook is not a PHP application like Pattern Lab was but instead a JavaScript one. So, the approach to get those working in Storybook is completely different. We don't have the full process documented, but here is the docs page that refers to the extensions used: https://docs.emulsify.info/details/twig-extensions

The basic idea of implementing them can be reverse engineered from our Emulsify Twig Extensions package and it's implementation in emulsify-drupal. You will need to write JS versions of those extensions (again, you can use ours as examples) and then make sure Twig.js has awareness of them like we do in that setupTwig.js file.

evanmwillhite commented 3 years ago

We also have an issue to make our docs more robust on this too https://github.com/emulsify-ds/documentation/issues/25

t3kn0ph34r commented 3 years ago

thanks @evanmwillhite !

evanmwillhite commented 3 years ago

Went ahead and did this since it was a need @t3kn0ph34r. Good luck! https://docs.emulsify.info/details/twig-extensions/add-a-custom-twig-extension