Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291828

Provide a Twig filter for cleaning up whitespace around classes.

$
0
0

Right now, when we add classes to a div, we do it this way:

<div class="content {{ attributes.class }}"{{ attributes }}>

This is alright, but it would be *better* if we could find some kind of filter for content_attributes.class that could eat the whitespace to the left of the twig print indicator {{ *only* when attributes.class is empty.

There are several alternatives to the way we are currently doing this.

1) Preprocess everything and add all classes into attributes early, instead of printing them in the templates.
- I think this is a bad idea because it will be harder for front-end devs to know which div is which if they all look the same in the template

2) Use Twig's whitespace controllers.
- Right now this does not work because the {{- controller removes the whitespace even when there is a class there, slamming two class names together and rendering them both useless. We would need to modify this behavior of twig in order to use these for our classes - something I hesitate to do.

3) Come up with a better alternative.
- I vote for this :) Ideas?


Viewing all articles
Browse latest Browse all 291828

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>