initial
This commit is contained in:
29
ts/index.ts
Normal file
29
ts/index.ts
Normal file
@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user