import { HPCCElement } from "./element"; export class Directive<_T> { } export class Ref extends Directive { constructor(public propertyName: keyof T & string) { super(); } } export interface HTMLTemplate { html: string; directives: Directive[]; } export function html(strings: TemplateStringsArray, ...values: Directive[]): HTMLTemplate { let html = strings[0]; const directives: Directive[] = []; for (let i = 0; i < values.length; ++i) { const arg = values[i]; if (arg instanceof Directive) { directives.push(arg); if (arg instanceof Ref) { html += `id="${arg.propertyName}"`; } else { html += String(values[i]); } } else { throw new Error("Invalid Directive"); } html += strings[i + 1]; } return { html, directives }; } export function ref(propertyName: keyof T & string): Ref { return new Ref(propertyName); }