-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support request re: using the drupal-attribute
class as an async Twing function
#535
Comments
I've just spotted ericmorand/drupal-attribute#9 (comment) but not sure if that helps with using |
What is the result that you get and what is your expected result? What you did looks fine to me. |
Hi @ericmorand, thank you for replying even at the weekend, I really appreciate it. So, if we use this example: {% set attributes = attributes|default(create_attribute()) %}
{% set attributes = attributes.addClass(['btn']) %}
<button {{ attributes }}>Stripped down example</button> Then the expected result would be: <button class="btn">Stripped down example</button> However, the result I am getting has no attributes at all: <button>Stripped down example</button> Would it be helpful if I could make you a CodeSandbox or a Git repo with a stripped back example? I opened up the |
I wonder if it's the |
I'm trying to use Twing in Storybook to demonstrate Twig templates that will be used on a Drupal 9 site.
I am using Twing
5.0.2
andtwing-loader
0.5.5
.In my environment file I am defining a
create_attribute
function like this:new drupalAttribute()
is a class that comes from @ericmorand 's https://github.com/ericmorand/drupal-attribute package.This package and approach worked perfectly in Twing 2 when functions did not return Promises:
So I am wondering if the async nature of Twing 5 is what is tripping me up?
My templates are rendering, but with no attributes, so I know I am doing something wrong. There's no
TwingErrorSyntax: Unknown "create_attribute" function
error though. It looks like mycreate_attribute
function can be found, but it is not usable by the templates because of how I have set things up at the moment.My templates are pretty basic, they look like this sort of thing:
Twing and using the JavaScript version of
create_attribute()
is new to me and I have a feeling I'm doing something silly. IsPromise.resolve(new drupalAttribute()),
likely to work or am I being over optimistic here? I read something about classes not being callable? I know this isn't a Twing issue (sorry) but I wondered if anyone here had encountered the same issue, especially as Eric is also a Twing maintainer.Other things I have tried
The text was updated successfully, but these errors were encountered: