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

add Meta suffix to meta getters #84

Merged
merged 1 commit into from Dec 10, 2020
Merged

add Meta suffix to meta getters #84

merged 1 commit into from Dec 10, 2020

Conversation

adrienpoly
Copy link
Contributor

as per this discussion #83 initiated by @leastbad

Getters now have by default a Metasuffix this.userIdMeta to remain as close as possible to the Value, Classand potentially Params api (hotwired/stimulus#249)

Example

// <head>
//   ...
//   <meta name="user_id" content="12345678">
//   <meta name="admin" content="true">
//   ...
// </head>

export default class extends Controller {
  static metaNames = ['user_id', 'admin']

  connect() {
    useMeta(this)

    // individual getters
    this.userIdMeta // 123456
    this.adminMeta // true

    // get all metas in one object
    this.metas // { userId: 123456, admin: true }
  }
}

@adrienpoly adrienpoly merged commit 07701c3 into master Dec 10, 2020
@adrienpoly adrienpoly deleted the meta-suffix branch December 10, 2020 12:05
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.

None yet

1 participant