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 constructor(opts: UseTemplateConstructor) { this.ref = opts.$.ref this.attributes = opts.$ } public toString(templates: Record): 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 } }