update to handlebars

This commit is contained in:
2017-02-25 23:40:15 +01:00
parent a5a8f5ae24
commit 0113d8ea19
8 changed files with 384 additions and 53 deletions

View File

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