O'Reilly logo

JavaScript Recipes: A Problem-Solution Approach by Keith Cirkel, Russ Ferguson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Russ Ferguson and Keith Cirkel 2017
Russ Ferguson and Keith CirkelJavaScript Recipes10.1007/978-1-4302-6107-0_14

14. Working with Template Literals

Russ Ferguson and Keith Cirkel2
(1)
Ocean, New Jersey, USA
(2)
London, UK
 

How Do You Use Template Literals?

Problem

You want to know how to use a template literal in a project.

Solution

Template literals are very similar to template systems like Handlebars . Template literals give you the ability to set placeholders for values and render them at runtime.

The Code

var characterName = 'Pinky'
var quote = `Same thing we do every night ${characterName}!`;
console.log(quote) //Same thing we do every night Pinky!
Listing 14-1.
Using Template Literals

How It Works

Template literals work in a similar way to using a template ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required