Last active
February 4, 2021 18:08
-
-
Save wiledal/a056f14145b01ce05a2deb970cd01720 to your computer and use it in GitHub Desktop.
Basic Template literals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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