Skip to content

Feature/add data attr to tag api - #31

Open
JaredShay wants to merge 2 commits into
lassebunk:masterfrom
JaredShay:feature/add-data-attr-to-tag-api
Open

JaredShay wants to merge 2 commits into
lassebunk:masterfrom
JaredShay:feature/add-data-attr-to-tag-api

Conversation

@JaredShay

Copy link
Copy Markdown

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