-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-uses-template.html
38 lines (36 loc) · 1.18 KB
/
02-uses-template.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
<head>
<title>02 - Template Literal para Html Fragments</title>
</head>
<body>
</body>
<script>
const article = {
title: 'Aprendendo Template Strings',
intro: 'Uma breve explicação de como se utilizar template strings do ES6 em seu código hoje!',
body: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias, officia, perspiciatis? Architecto, molestias autem. Repellat, laborum deserunt soluta necessitatibus. Tenetur illo, id magnam numquam neque illum temporibus, in qui eos.',
tags: ['es6', 'js', 'template-literal']
};
function renderAuthor(name) {
return (name) ? name : 'unknown';
}
const markup = `
<article>
<header>
<h1>${article.title}</h1>
</header>
<section>
<p>${article.intro}</p>
</section>
<footer>
<ul>
${article.tags.map((tag) => `<li>${tag}</li>`).join('')}
</ul>
<p>Author: ${renderAuthor(article.author)}</p>
</footer>
</article>
`;
document.body.innerHTML = markup;
</script>
</html>