- 🇫🇷France aiphes
Suscribe to this, it's very complicated to add Classes to expression or elements / sub-elements.
Currently it is not possible to access various properties of twig variables in templates which makes some operations huge pita.
For example have a look at Classy's menu-local-task.html.twig template:
<li{{ attributes.addClass(is_active ? 'is-active') }}>{{ link }}</li>
it is not possible to give the class to the link itself, instead we can only print the (global)attributes on their own and so to have the active class we can only give it to the list item.
Another example can be theming forms. For example you want to add a bootstrap or foundation class to your submit buttun but you cannot since you cannot access attributes of form.submit
(for example). Instead you have to wrap such variable into another html element and assign class to it which won't work in this example since both of these frameworks require the class(alert, button, tiny...) to be applied to the form element directly.
I think Drupal should allow to traverse the variables(if the developer/themer knows the structure) in a way that allows manipulating the data before it is rendered. Since at this moment we have to use, in many many cases, the theme's theme file which basically means we are hard coding css classes(in this example) instead of making them part of the template as they should.
We have the NestedArray
class so maybe some Twig extension could be built upon it.
Active
10.1 ✨
Last updated
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Suscribe to this, it's very complicated to add Classes to expression or elements / sub-elements.