Skip to main content

@microsoft/fast-element > compileTemplate

compileTemplate() function

Compiles a template and associated directives into a raw compilation result which include a cloneable DocumentFragment and factories capable of attaching runtime behavior to nodes within the fragment.

Signature:
export declare function compileTemplate(template: HTMLTemplateElement, directives: ReadonlyArray<HTMLDirective>): CompilationResult;

Parameters

ParameterTypeDescription
templateHTMLTemplateElementThe template to compile.
directivesReadonlyArray<HTMLDirective>The directives referenced by the template.
Returns:

CompilationResult

Remarks

The template that is provided for compilation is altered in-place and cannot be compiled again. If the original template must be preserved, it is recommended that you clone the original and pass the clone to this API.