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

Apply consistent symbol/string attribute transformation for Hash values #610

Merged
merged 1 commit into from Dec 6, 2023

Conversation

willcosgrove
Copy link
Contributor

Symbol attribute keys are dasherized before rendering, whereas string keys are passed through verbatim.

However if the value is a Hash, the dasherize transform will not be applied to the key even if it is a symbol. This change makes it so the dasherization is applied even in this case.

a(data_turbo: { method: "post", confirm: "Are you sure?" })

Should render

<a data-turbo-method="post" data-turbo-confirm="Are you sure?"></a>

Symbol attribute keys are dasherized before rendering, whereas string
keys are passed through verbatim.

However if the value is a Hash, the dasherize transform will not be
applied to the key even if it is a symbol. This change makes it so the
dasherization is applied even in this case.

```rb
a(data_turbo: { method: "post", confirm: "Are you sure?" })
```

Should render

```html
<a data-turbo-method="post" data-turbo-confirm="Are you sure?"></a>
```
@willcosgrove willcosgrove force-pushed the dasherize-symbol-hash-attributes branch from 5d3b221 to bd65bd5 Compare December 5, 2023 22:53
Copy link
Collaborator

@joeldrapper joeldrapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@joeldrapper joeldrapper merged commit 3e10cc0 into main Dec 6, 2023
17 checks passed
@joeldrapper joeldrapper deleted the dasherize-symbol-hash-attributes branch December 6, 2023 10:18
@joeldrapper joeldrapper added this to the 1.10 milestone Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants