Skip to content

Instantly share code, notes, and snippets.

@Zaggen
Created January 19, 2017 03:47
Show Gist options
  • Save Zaggen/ff37906d13b9ce48b5452bc051a136a5 to your computer and use it in GitHub Desktop.
Save Zaggen/ff37906d13b9ce48b5452bc051a136a5 to your computer and use it in GitHub Desktop.
declare const _: _.LoDashStatic
import {template} from '../helpers/index'
interface BackBoneComponent {
el?: string,
template?: string | Function,
events?: any,
subComponents?: any[],
[key: string]: any
}
// TODO: Modify type definitions to use Backbone.View instead of any
export function component(definition: BackBoneComponent) {
return function decorator(constructor: any) {
if(typeof definition.template === 'string'){
definition.template = template(<string> definition.template)
}
_.extend((constructor as any).prototype, {subComponents: []}, definition)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment