using template literals to create html

Solutions on MaxInterview for using template literals to create html by the best coders in the world

showing results for - "using template literals to create html"
Paula
24 Nov 2016
1const createMarkup = function createMarkup(data) {
2  // Just use the same syntax for node elements
3  const markup = 
4    `<ul id="listItem-${data.name}">
5      <li>Name: ${data.name}</li>
6      <li>Age: ${data.age}</li>
7      <li>Gender: ${data.gender}</li>
8      <li>Fav. Colour: ${data.colour}</li>
9      <li>Lucky Number: ${data.number}</li>
10    </ul>`;return markup;
11};
River
30 Jul 2016
1// Create our object
2const person = {
3    name: 'TopCoder2021',
4    job: 'Software Developer,
5    city: 'Los Angeles',
6    bio: 'Tony is a really cool guy that loves to code!'
7}
8
9// And then create our markup:
10const markup = `
11 <div class="person">
12    <h2>
13        ${person.name}
14    </h2>
15    <p class="location">${person.city}</p>
16    <p class="bio">${person.bio}</p>
17 </div>
18`;
19
20document.body.innerHTML = markup
queries leading to this page
javascript template htmlnodejs html template literaljavascript html template literalhow to render html in template literalscreate html element using template literaltemplate literals in htmltemplate literal with htmlinject html with template literalshtml to tamplae literaljavascript add html to template literaltemplate literals htmhow to add html in template literalshow to add html in template stringstring template literal html tagtemplate html string literalhtml template literalshow to write template literal in htmltemplate literals in javascript and htmltemplate literals htmltemplate literals javascript htmlbuild html template literalsjavascript template literals htmlhow to use template literals in htmlcreate new html element with template literals in javascriptadding html in template literalhtml in template literalhow to use html tag in js template literaltemplate literals with html tagstemplate literals add htmlhtml to js using template literalstemplate literals building html templatestemplate literals htmlhtml tags in template literalstemplate literals safe htmljavascript template literal htmltemplate literals javascript w3schoolstemplate literal htmltemplate literals html pagejavascript html templatejavascript template literals w3schoolsusing template literals to create htmlhtml file in template literalhtml string templatehtml tag using template literalhtml tag in template literalstemplate literal in htmlhtml template string literal javascripttemplate literals with htmlformat html in template literalhow do i use literals in html templatehtml inside template literal writing html tags in template literalsjs template literals htmlhtml literal stringtemplate literal from js into htmltemplate literal js w3adding html to template literal html file in template literaltemplate literal with html elementjs template literal html codehow to create html template literalshtml tag with template literalhtml template literaltemplate literals html tagshow to write html tag in js template literalhtml template literals 22html 60 22html format in template literaluse template literal in htmlusing template literals to create html