Skip to main content
Version: 2.x

ViewTemplate.create() method

@microsoft/fast-element > ViewTemplate > create

ViewTemplate.create() method

Creates a template based on a set of static strings and dynamic values.

Signature:

static create<TSource = any, TParent = any>(strings: string[], values: TemplateValue<TSource, TParent>[], policy?: DOMPolicy): ViewTemplate<TSource, TParent>;

Parameters

Parameter

Type

Description

strings

string[]

The static strings to create the template with.

values

TemplateValue<TSource, TParent>[]

The dynamic values to create the template with.

policy

DOMPolicy

(Optional) The DOMPolicy to associated with the template.

Returns:

ViewTemplate<TSource, TParent>

A ViewTemplate.

Remarks

This API should not be used directly under normal circumstances because constructing a template in this way, if not done properly, can open up the application to XSS attacks. When using this API, provide a strong DOMPolicy that can properly sanitize and also be sure to manually sanitize all static strings particularly if they can come from user input.