I had to do a little RTFMing today, and so I thought I'd post about it. First of all, this is how you set up PhpStorm to use ES6 eslint settings. You may find it useful Is the linter getting in your way? The first way to override an eslint setting is inline, disabling it on a one-off basis. If you truly need a new .eslintrc.json file, then you should probably extend the one from Drupal core. Here's how the linter looks for eslint files. TL;DR: like .gitignore files. Finally, here's how the extends property of eslintrc.json…
Read more about Overriding Drupal 8's .eslintrc.json File in Your Theme With Extends◆
I had a very strange problem wherein I was not able to affect variables being passed to views-view-grid--my_view.html.twig. function mytheme_preprocess_views_view(&$vars) { if ($vars['view']->id() == 'myview') { $vars['amaaaazingVar'] = '!'; } } Yet, sadly, there was no amaaaazingVar to be found in views-view-grid--my_view.html.twig when I did {{ kint() }}. What did I do? I set a breakpoint in the twig template using this methodology and then looked back through to see what preprocess functions were being called by the theme. And yes... my preprocess function was called. But the variables weren't getting saved. Strange. Why were my variables clobbered…
Read more about D8: Variables in template_preprocess_views_view not passed to twig◆
On the method of disabling a block without recourse to path…
Read more about D8: Disable Block Programmatically on Just One View or Node◆
On the method of creating custom breadcrumbs: simply crumble stale bread and dip battered eggs into your bowl. But in Drupal…
Read more about Drupal 8.3: Create Programmatic Custom Breadrumb◆
Sometimes, you've got a Drupal twig function that doesn't exist in PatternLab, and it prevents PatternLab from building. You get an "Unknown filter" error. What you need to do is create a Twig stub that does either what you need it to, or nothing at all. In emulsify, twig functions exist at emulsify/components/_twig-components/filters. For example, to create a typogrify filter, create a file called typogrify.filter.php…
Read more about Add a New Twig Function in Patternlab◆
So, your debug output isn't working. You checked to make sure you followed all the steps here. But still... no theme debug output. WTF? Try turning on and off twig caching. For me, it seemed something was stuck or whatever. First turn it on: twig.config: debug: true auto_reload: true cache: true Then do drush cr. Then turn it off: twig.config: debug: true auto_reload: true cache: false Then do drush cr. Sometimes the code that makes Drupal run can kind of pile up and get stuck, like a logjam in a river. This just clears the blockage. Just kidding…
Read more about Twig/Theme Debug Not Working Even Though Set◆
It turns out that image style tokens are an easter egg of the regular Token module, ported in from the Imagecache Token module on this ticket. Image style tokens don't show up in the media browser, and so you sort of have to guess at how to use them. I figured it out by studying the merged commit that added the functionality…
Read more about Drupal 8: How to Get Image Style Tokens for Metatags◆
Pluralizing and singularizing words got very easy with the inclusion of the Doctrine Inflector class in Drupal 8 core. use Doctrine\Common\Inflector\Inflector; $pluralized = Inflector::pluralize($bundle_singular); $singularized = Inflector::singularize($bundle_singular); You can read more about the Doctrine Inflector class here…
Read more about How to Pluralize and Singularize a Word in Drupal 8◆
The task at hand here is to allow the client to create a classed wrapper around multiple elements using CKEditor in Drupal 8. The fundamental problem here is the CKEditor's built in "Styles" dropdown classes each individually, while we need a class wrapping them. You could probably make or install your own CKEditor plugin, but that's not what I did. I did this with Javascript…
Read more about Add Multi-Element Wrapper Class With CKEditor in Drupal 8