Last active
May 5, 2016 03:22
-
-
Save IAmJulianAcosta/79048dd927b7655bfa3fb1efb578fb4f to your computer and use it in GitHub Desktop.
Get Ember object simple name from complex name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Returns a string with full name of component, like: <ProjectName@component:path/to/component-name::ember793> | |
let componentName = this.toString (); | |
//This regex will match the component and capture the latest part of component path. | |
let regex = componentName.match (/<[a-zA-Z]+@[a-zA-Z]+:(?:[a-z]+[\/])*([-a-z]+)::[a-zA-Z]+[0-9]+>/); | |
//The latest element of array is the component name. | |
console.log (regex[regex.length-1]); //component-name | |
//See: https://regex101.com/r/rX9bQ7/3 for explanation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment