API @deepkit/template
npm install @deepkit/template
Tell the template engine to not automatically escape the HTML in the given string.
Per default all dynamic values are automatically HTML escaped. This is dangerous: Always validate data that you pass as Classes
export abstract class ElementClass {
constructor(protected attributes: Attributes);
abstract render(): Element;
}
Const
{ [name: string]: true; }
unique symbol
Functions
(string: string | HtmlString): HtmlString
string
otherwise this can lead
to Cross-Side Scripting attacks.(v: any): v is ElementStruct
(v: any): v is SafeString
(injector: Injector, struct: ElementStruct | string | (ElementStruct | string)[], stopwatch?: Stopwatch): Promise<any>
(element: Element, attributes?: Attributes | null, ...children: (string | ElementStruct | HtmlString)[]): { render: Element; attributes: Attributes<any>; children: (string | ... 1 more ... | HtmlString)[]; }
(code: string, filename: string): string
(code: string): any
(ast: Node): any
(e: Expression | SpreadElement): string | typeof noStaticValue
(e: Expression | SpreadElement): boolean
(code: string): string
(code: string): string
Types
type Attributes<T = any> = {
[P in keyof T]: T[P];
} & { children?: (ElementStruct | string)[] | ElementStruct | string };
interface ElementFn {
(attributes: Attributes, children: HtmlString | string): Element;
}
type Element = string | ElementFn | ClassType<ElementClass> | Element[];
type ElementStruct = { render: string | ElementFn, attributes: Attributes | null | string, children: ElementStructChildren | ElementStructChildren[], childrenEscaped?: ElementStructChildren[] | string };
type SafeString = { [safeString]: string };