liveBook · Manning

Template

As explained in JavaScript in Depth

The process of producing structured text output by combining fixed template content with dynamic data.

Template generation produces structured text by combining fixed content with dynamic data. In JavaScript, repeatedly appending generated pieces inside a loop can require increasingly costly allocation and copying; under naïve copying, the work grows quadratically. section 2.2.1

<h1>{{title}}</h1>
<p>Hello {{name}}, you have {{count}} unread messages.</p>

This HTML template marks dynamic values with placeholders. section 2.2.1

Building a user table

A loop appends one HTML row per user with +=. This illustrates how a familiar rendering task can expose the cost of repeated concatenation. section 2.2.1

How JavaScript in Depth covers it

How deep it goes
Explains repeated concatenation's allocation and copying costs, including quadratic growth under a naïve copying model.
Examples
Uses placeholder-based HTML, a user table, nested menus, and large generated collections to expose costs.
What you can do after
Diagnose performance risks by recognizing repeated string concatenation in loops as a potential quadratic-cost pattern.
How it connects
Connects template generation to JavaScript strings, string concatenation, and performance.

Also explained in

Compare how 29 books explain template →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of JavaScript in Depth. The section links point to the parts of the book it draws on.