Skip to content
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

Not sure if bug or feature #4

Closed
lokmanm opened this issue Sep 12, 2023 · 6 comments
Closed

Not sure if bug or feature #4

lokmanm opened this issue Sep 12, 2023 · 6 comments

Comments

@lokmanm
Copy link

lokmanm commented Sep 12, 2023

Hey John, as always love your work!

We use this package heavily with our sites and just recently stumbled upon a thing but I am not sure if it's a bug or a feature.

I am trying to set the value of an alpine data based on the handle. In this case, the handle is the antlers value that I am trying to increase or decrease.

A blade component inside an antlers file for example:

field.antlers.html

<x-button @click="{{ handle }}++">
  Submit
</x-button>

This will not work and the attribute is not evaluated at all. However, this does work:

<x-button @click="{handle}++">
  Submit
</x-button>

Is it okay if we keep using the second option? Or do you think its a bug and the first one should work.

Thanks!

@JohnathonKoster
Copy link
Contributor

The second option should always work - I'll do some reviews to verify though (and see what might be happening in the first example) 🙂

@lokmanm
Copy link
Author

lokmanm commented Sep 12, 2023

@JohnathonKoster thanks a lot!

On another note, this also does not work inside an antlers file:

<x-input
    type="{input_type ?? 'text'}"
    name="{handle}"
    value="{value}"
    {{ js_attributes }}
/>

js_attributes is not being passed down to x-input.

x-input is a Blade component that has the necessary styling.

Am I missing anything? Thanks again.

@JohnathonKoster
Copy link
Contributor

@JohnathonKoster thanks a lot!

On another note, this also does not work inside an antlers file:

<x-input
    type="{input_type ?? 'text'}"
    name="{handle}"
    value="{value}"
    {{ js_attributes }}
/>

js_attributes is not being passed down to x-input.

x-input is a Blade component that has the necessary styling.

Am I missing anything? Thanks again.

I don't think parameters like that ({{ js_attributes }}) are currently supported. I'd have to dig to see what the variable names look like in the Core blade compiler to determine what should happen there (and tons of edge cases to consider) - will give it a shot while reviewing the other items

@lokmanm
Copy link
Author

lokmanm commented Sep 12, 2023

@JohnathonKoster Ah sorry, I guess I hit some edge cases while tinkering.

No worries though, I love the package so far! Copy-pasting classes will do for now.

@JohnathonKoster
Copy link
Contributor

I've tagged version 2.1.0, which makes a few improvements here 🙂

The following will now compile to equivalent Antlers code behind the scenes:

<x-button @click="{{ handle }}++">
  Submit
</x-button>

<x-button @click="{handle}++">
  Submit
</x-button>

In addition to that improvement, I've also added support for compiling arbitrary variable echos like this:

<x-input
    type="{input_type ?? 'text'}"
    name="{handle}"
    value="{value}"
    {{ js_attributes }}
/>

The previous example would be equivalent to the following in regular Antlers:

{{ tag_name :js_attributes="js_attributes" }}

If the input is more complicated like so:

<x-input
    type="{input_type ?? 'text'}"
    name="{handle}"
    value="{value}"
    {{ js_attributes | upper }}
/>

it is equivalent to the following:

{{ tag_name js_attributes="{js_attributes | upper}" }}

@lokmanm
Copy link
Author

lokmanm commented Sep 15, 2023

@JohnathonKoster thanks a lot 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants