/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ // The first argument to JS template tags retain identity across multiple // calls to a tag for the same literal, so we can cache work done per literal // in a Map. export const templateCaches = new Map>(); /** * Interprets a template literal as an HTML template that can efficiently * render to and update a container. */ export const html = (strings: TemplateStringsArray, ...values: any[]) => new TemplateResult(strings, values, 'html'); /** * Interprets a template literal as an SVG template that can efficiently * render to and update a container. */ export const svg = (strings: TemplateStringsArray, ...values: any[]) => new SVGTemplateResult(strings, values, 'svg'); /** * The return type of `html`, which holds a Template and the values from * interpolated expressions. */ export class TemplateResult { strings: TemplateStringsArray; values: any[]; type: string; partCallback: PartCallback; constructor( strings: TemplateStringsArray, values: any[], type: string, partCallback: PartCallback = defaultPartCallback) { this.strings = strings; this.values = values; this.type = type; this.partCallback = partCallback; } /** * Returns a string of HTML used to create a