# API `@deepkit/template`

```shell
npm install @deepkit/template
```

## API reference of @deepkit/template

### html (function)

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 `string` otherwise this can lead
to Cross-Side Scripting attacks.

```typescript
(string: string | HtmlString): HtmlString
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L39

### isElementStruct (function)

```typescript
(v: any): v is ElementStruct
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L78

### isSafeString (function)

```typescript
(v: any): v is SafeString
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L82

### render (function)

```typescript
(injector: Injector, struct: ElementStruct | string | (ElementStruct | string)[], stopwatch?: Stopwatch): Promise<any>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L116

### createElement (function)

```typescript
(element: Element, attributes?: Attributes | null, ...children: (string | ElementStruct | HtmlString)[]): { render: Element; attributes: Attributes<any> | null | undefined; children: (string | ... 1 more ... | HtmlString)[]; }
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L222

### Attributes (type)

```typescript
type Attributes<T = any> = {
    [P in keyof T]: T[P];
} & { children?: (ElementStruct | string)[] | ElementStruct | string };
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L17

### ElementClass (class)

```typescript
export abstract class ElementClass {
    constructor(protected attributes: Attributes);
    abstract render(): Element;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L21

### ElementFn (type)

```typescript
interface ElementFn {
    (attributes: Attributes, children: HtmlString | string): Element;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L47

### Element (type)

```typescript
type Element = string | ElementFn | ClassType<ElementClass> | Element[];
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L51

### voidElements (variable)

```typescript
{ [name: string]: true; }
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L53

### ElementStruct (type)

```typescript
type ElementStruct = { render: string | ElementFn, attributes: Attributes | null | string, children: ElementStructChildren | ElementStructChildren[], childrenEscaped?: ElementStructChildren[] | string };
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L74

### SafeString (type)

```typescript
type SafeString = { [safeString]: string };
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/template.ts#L76

### transform (function)

```typescript
(code: string, filename: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/optimize-tsx.ts#L37

### parseCode (function)

```typescript
(code: string): Node
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/optimize-tsx.ts#L101

### generateCode (function)

```typescript
(ast: Node): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/optimize-tsx.ts#L105

### extractStaticString (function)

```typescript
(e: Expression | SpreadElement): string | typeof noStaticValue
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/optimize-tsx.ts#L639

### isOptimisedHtmlString (function)

```typescript
(e: Expression | SpreadElement): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/optimize-tsx.ts#L758

### optimizeJSX (function)

```typescript
(code: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/optimize-tsx.ts#L920

### convertJsxCodeToCreateElement (function)

```typescript
(code: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/optimize-tsx.ts#L933

### noStaticValue (variable)

```typescript
unique symbol
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/template/src/optimize-tsx.ts#L637
