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

Feature/add data attr to tag api #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JaredShay
Copy link

What is this change?

This introduces a new feature that enhances the api to accept a data attribute.

meta(
  tag_type: {
    value: 'value',
    data: { 'data-attr-name' => 'data attr value' }
  }
)

Multiple data attributes can be specified:

meta(
  tag_type: {
    value: 'value',
    data: { 'attr-1' => 'one', 'attr-2' => 'two' }
  }
)

Custom tags can be registered:

Metamagic::Renderer.register_tag_type :custom, ->(key, value, data) do
  tag(:custom_tag, name: key, value: value, data: data)
end

This is backwards compatible with the existing api.

Why was this change introduced?

This change was motivated by the Helmet library which requires that a data attribute be set on meta tags in order for them to be managed client side.

This test failed as the meta value in the hashes were arrays with
elements in different orders. I'm not sure if this matters but the test
description makes suggests that perhaps order is important here and this
is in fact a real failure. I've left a comment in order to do more
investigation at a future point.
This introduces a new feature that enhances the api to accept a data
attribute.

```
meta(
  tag_type: {
    value: 'value',
    data: { 'data-attr-name' => 'data attr value' }
  }
)
```

Multiple data attributes can be specified:

```
meta(
  tag_type: {
    value: 'value',
    data: { 'attr-1' => 'one', 'attr-2' => 'two' }
  }
)
```

Custom tags can be registered:

```
Metamagic::Renderer.register_tag_type :custom, ->(key, value, data) do
  tag(:custom_tag, name: key, value: value, data: data)
end
```

This is backwards compatible with the existing api.
@JaredShay JaredShay force-pushed the feature/add-data-attr-to-tag-api branch from 059f974 to bd67db8 Compare November 8, 2022 15:31
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

Successfully merging this pull request may close these issues.

1 participant