smartmustache/ts/index.ts
2016-11-20 17:41:26 +01:00

30 lines
625 B
TypeScript

import * as mustache from 'mustache'
/**
* class Tlt allows templates to be used with different sets of data
*/
export class Tlt {
templateString: string
/**
* constructor of class Tlt
*/
constructor(templateStringArg: string) {
this.templateString = templateStringArg
}
/**
* returns template string with data applied
*/
applyData(data: any): string {
return mustache.render(this.templateString, data)
}
/**
* set a new template string
*/
setTemplate(templateStringArg: string) {
this.templateString = templateStringArg
}
}