-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constructor of Attribute doesn't match Drupal core #1
Comments
It looks like Twig.js converts the Twig associative array syntax into a JS object internally. And trying to pass an object to Attribute's constructor errors with |
Hi @JohnAlbin, I think I have a fix for this, and also a way to get property-access working in both Twing and Twig.js (the |
For context, here is my feature-branch that has all Diff: main...MichaelAllenWarner:drupal-twig-extensions:fix-create_attributes (So the "big PR" would be for all this.) |
The current implementation of Attribute uses a JavaScript Map internally, which is an excellent choice.
But the constructor of Attribute just re-uses the Map constructor, so usage is:
or in a Twig file:
See the Map constructor docs:
But that doesn't match the syntax we'd use inside Drupal twig files because Twig associative arrays use an object-like syntax:
I've implemented a work-around inside the
create_attribute()
Twig function.The fault is either in:
We either need to provide a patch upstream or fork
drupal-attribute
into this project.Docs for Drupal's Attribute object are here: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Template%21Attribute.php/class/Attribute/9.1.x
The text was updated successfully, but these errors were encountered: