smartmustache/ts/index.ts

30 lines
625 B
TypeScript
Raw Normal View History

2016-11-20 16:41:26 +00:00
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
}
}