Sha256: c8520df8e7787ffeedc021871942940de9b2d9e34a28e3424607f4efaf38c7e4
Contents?: true
Size: 550 Bytes
Versions: 17
Compression:
Stored size: 550 Bytes
Contents
import { htmlAttributes } from "../html/html-attributes"; export class Element { attributes: Record<string, any>; children: any[]; type: string; constructor(type: string, attributes: Record<string, any> = {}) { this.children = []; this.type = type; this.attributes = attributes; } get render(): string { return `<${this.type} ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</${this.type}>`; } add(child: any): Element { this.children.push(child); return this; } }
Version data entries
17 entries across 17 versions & 1 rubygems