Last active
February 11, 2017 14:19
-
-
Save nchanged/37f19b2aed15cb601581955cc9c303c1 to your computer and use it in GitHub Desktop.
fusebox-dec-sample.js
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
export function componentDecorator() { | |
return function(target, key: string, descriptor: PropertyDescriptor) { | |
let fileName = Reflect.getMetadata(“fusebox: __filename”, target, key); | |
let dirName = Reflect.getMetadata(“fusebox: __dirname”, target, key); | |
let requireDeatils = Reflect.getMetadata(“fusebox: require”, target, key); // Local “require” function | |
let moduleDetails = Reflect.getMetadata(“fusebox: module”, target, key); | |
let exportsCollection = Reflect.getMetadata(“fusebox: exports”, target, key); | |
//load CSS by convention | |
let cssFileName = fileName.replace(`.js`, `.css`); | |
require(cssFileName); | |
//load html template by convention | |
let htmlFileName = fileName.replace(`.js`, `.html`); | |
target.template = require(htmlFileName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment