Skip to content

Commit 68c7155

Browse files
authored
Merge pull request #1 from MSoup/MSoup-list-group-item
Fix class="list-group-item}" to "list-group-item"
2 parents 13dbc5c + c52a41f commit 68c7155

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

manuscript/02.ECMAScript2015.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ If you take a look at the ES5 that this gets compiled down to, it makes a whole
100100

101101
Looking at this compiled code with such a simple example also makes this syntax seems a little silly, but it gets a whole lot more interesting when you consider a more real-world example. For instance, let's assume we want to use this chunk of HTML as a template to render the details of a Todo:
102102

103-
<div todo='[[Todo ID]]' class="list-group-item}">
103+
<div todo='[[Todo ID]]' class="list-group-item">
104104
<i class="[[ If Todo is complete, then "hidden" ]] text-success glyphicon glyphicon-ok"></i>
105105
<span class="name">[[Name]]</span>
106106
</div>
@@ -112,7 +112,7 @@ So, let's avoid all of that by converting this into a string template instead.
112112
The first thing to do is wrap the HTML in backticks.
113113

114114
container.innerHTML = `
115-
<div todo='[[Todo ID]]' class="list-group-item}">
115+
<div todo='[[Todo ID]]' class="list-group-item">
116116
<i class="[[ If Todo is complete, then "hidden" ]] text-success glyphicon glyphicon-ok"></i>
117117
<span class="name">[[Name]]</span>
118118
</div>
@@ -132,7 +132,7 @@ Then, rather than doing those search-and-replace operations, we can insert the v
132132
}
133133

134134
container.innerHTML = `
135-
<div todo='${todo.id}' class="list-group-item}">
135+
<div todo='${todo.id}' class="list-group-item">
136136
<i class="[[ If Todo is complete, then "hidden" ]] text-success glyphicon glyphicon-ok"></i>
137137
<span class="name">${todo.name}</span>
138138
</div>
@@ -143,7 +143,7 @@ One of the cool things about string templates is that you don't have to restrict
143143
For example, I can figure out whether or not to render the "hidden" class on the icon element dynamically by introducing a conditional statement right there in the expression, like this:
144144

145145
container.innerHTML = `
146-
<div todo='${todo.id}' class="list-group-item}">
146+
<div todo='${todo.id}' class="list-group-item">
147147
<i class="${ todo.completed ? "" : "hidden" } text-success glyphicon glyphicon-ok"></i>
148148
<span class="name">${todo.name}</span>
149149
</div>
@@ -153,7 +153,7 @@ When the value of todo.completed is true, the expression will evaluate to an emp
153153

154154
{title="app.js"}
155155
~~~
156-
container.innerHTML = "\n\t <div todo='" + todo.id + "' class=\"list-group-item}\">\n\t <i class=\"[[ If Todo is complete, then \"hidden\" ]] text-success glyphicon glyphicon-ok\"></i>\n\t <span class=\"name\">" + todo.name + "</span>\n\t </div>\n\t";
156+
container.innerHTML = "\n\t <div todo='" + todo.id + "' class=\"list-group-item\">\n\t <i class=\"[[ If Todo is complete, then \"hidden\" ]] text-success glyphicon glyphicon-ok\"></i>\n\t <span class=\"name\">" + todo.name + "</span>\n\t </div>\n\t";
157157
~~~
158158

159159
Once again, inspecting the compiled JavaScript reveals that - even with inline conditional statements and everything - this syntax eventually just ends up as a series of concatenated strings and expressions.

0 commit comments

Comments
 (0)