Using drupal-attribute with filters
Hi Eric,
I am currently trying to use Drupal Attributes (using your https://github.com/ericmorand/drupal-attribute) with Twing, which seems to work fine when calling methods like addClass in JS context, but not in Twing context. I took the browser example from the Twing documentation and changed it a bit:
const {createEnvironment, createArrayLoader} = Twing;
const loader = createArrayLoader({
'index.twig': '{{ name }} / {{ name.addClass("bar") }}'
});
const environment = createEnvironment(loader);
environment.render('index.twig', {
name: new DrupalAttribute().addClass("foo"),
}).then((output) => {
document.querySelector("pre").textContent = output;
});
The output in this case will be class="foo" /. When using dump, you can see that a Drupal attribute becomes NULL whenever you call any of the Drupal Attribute methods on it inside a template.
I am not a 100% sure that it is an issue with Twing, but I assume so, as calling those methods outside of a template works fine.
I used the current version of Twing on jsdelivr.net as well as 7.1.0-beta.2. Happens in both versions.
Thanks a lot, Michael