Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 9c8d62f

Browse files
committed
Merge pull request #2938 from TomMalbran/tom/update-list
Move the Update List information to a template
2 parents dde9848 + 0619fb8 commit 9c8d62f

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

src/htmlContent/update-list.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{#.}}
2+
<div>
3+
<h3>{{versionString}} - {{dateString}} (<a href="#" data-url="{{releaseNotesURL}}">{{RELEASE_NOTES}}</a>)</h3>
4+
<ul>
5+
{{#newFeatures}}
6+
<li><b>{{name}}</b> - {{description}}</li>
7+
{{/newFeatures}}
8+
</ul>
9+
</div>
10+
{{/.}}

src/utils/UpdateNotification.js

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ define(function (require, exports, module) {
3737
Strings = require("strings"),
3838
StringUtils = require("utils/StringUtils"),
3939
Global = require("utils/Global"),
40-
UpdateDialogTemplate = require("text!htmlContent/update-dialog.html");
40+
UpdateDialogTemplate = require("text!htmlContent/update-dialog.html"),
41+
UpdateListTemplate = require("text!htmlContent/update-list.html");
4142

4243
// Extract current build number from package.json version field 0.0.0-0
4344
var _buildNumber = Number(/-([0-9]+)/.exec(brackets.metadata.version)[1]);
@@ -198,32 +199,9 @@ define(function (require, exports, module) {
198199
// Populate the update data
199200
var $dlg = $(".update-dialog.instance");
200201
var $updateList = $dlg.find(".update-info");
202+
var templateVars = $.extend(updates, Strings);
201203

202-
// TODO: Use a template instead of hand-rolling HTML code
203-
updates.forEach(function (item, index) {
204-
var $features = $("<ul>");
205-
206-
item.newFeatures.forEach(function (feature, index) {
207-
$features.append(
208-
"<li><b>" +
209-
StringUtils.htmlEscape(feature.name) +
210-
"</b> - " +
211-
StringUtils.htmlEscape(feature.description) +
212-
"</li>"
213-
);
214-
});
215-
216-
var $item = $("<div>")
217-
.append("<h3>" +
218-
StringUtils.htmlEscape(item.versionString) +
219-
" - " +
220-
StringUtils.htmlEscape(item.dateString) +
221-
" (<a href='#' data-url='" + item.releaseNotesURL + "'>" +
222-
Strings.RELEASE_NOTES +
223-
"</a>)</h3>")
224-
.append($features)
225-
.appendTo($updateList);
226-
});
204+
$updateList.html(Mustache.render(UpdateListTemplate, templateVars));
227205

228206
$dlg.on("click", "a", function (e) {
229207
var url = $(e.target).attr("data-url");

0 commit comments

Comments
 (0)