Skip to content

Instantly share code, notes, and snippets.

@ehyland
Created November 29, 2017 04:55
Show Gist options
  • Save ehyland/2d50ba166cf5d2c067ce81574347a1ec to your computer and use it in GitHub Desktop.
Save ehyland/2d50ba166cf5d2c067ce81574347a1ec to your computer and use it in GitHub Desktop.
Ember auto data-semantic
Ember.Component.reopen({
setDataSemantic: Ember.on('init', function() {
const defaultDataSemantic = Ember.meta(this).factory.fullName
.replace(/^component:/, '')
.replace(/\//, '--');
if (this.get('tag')) {
this.set('attributeBindings', ['dataSemantic:data-semantic']);
this.set('data-semantic', defaultDataSemantic);
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment