Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import Template from './Template'
export type UseTemplateAttributes = { ref: string, [key: string]: string }
export type UseTemplateConstructor = { '$': UseTemplateAttributes }
export default class UseTemplate {
public $: UseTemplateAttributes
public ref: string
public attributes: Record<string, string>
constructor(opts: UseTemplateConstructor) {
this.ref = opts.$.ref
this.attributes = opts.$
}
public toString(templates: Record<string, Template>): string {
let content = templates[this.ref].Text
for (const [key, value] of Object.entries(this.attributes)) {
content = content.replace(new RegExp(`{${key}}`, 'g'), value)
}
return content
}
}
|