Skip to content

Instantly share code, notes, and snippets.

@wiledal
Last active February 4, 2021 18:08
Show Gist options
  • Select an option

  • Save wiledal/a056f14145b01ce05a2deb970cd01720 to your computer and use it in GitHub Desktop.

Select an option

Save wiledal/a056f14145b01ce05a2deb970cd01720 to your computer and use it in GitHub Desktop.
Basic Template literals
var copy = {
title: 'Discovering Template Literals',
subtitle: 'Effortless client-side rendering awaits.',
body: 'You will never want to go back to normal strings again.'
}
var element = document.createElement('section')
element.innerHTML = `
<div class="content">
<h1>${copy.title}</h1>
<p class="subtitle">${copy.subtitle}</p>
<p>${copy.body}</p>
</div>
`
/*
Results:
<section>
<div class="content">
<h1>Discovering Template Literals</h1>
<p class="subtitle">Effortless client-side rendering awaits.</p>
<p>You will never want to go back to normal strings again.</p>
</div>
</section>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment