Skip to content

Commit e179c8f

Browse files
author
Seth Kinast
committed
Release v2.6.0
1 parent 7caab5e commit e179c8f

File tree

8 files changed

+129
-49
lines changed

8 files changed

+129
-49
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
## Change Log
22

3+
### v2.6.0 (2015/03/05 18:00 +00:00)
4+
- [#545](https://github.com/linkedin/dustjs/pull/545) New dust command-line compiler (@sethkinast)
5+
- [#536](https://github.com/linkedin/dustjs/pull/536) Add AMD (require.js) compatibility (@sethkinast)
6+
- [#543](https://github.com/linkedin/dustjs/pull/543) Replaced util.print/util.puts with console.log (@hunterchristian)
7+
- [#541](https://github.com/linkedin/dustjs/pull/541) Escape template names (@aredridel)
8+
- [#540](https://github.com/linkedin/dustjs/pull/540) Escape values when using json filter (@jimmyhchan)
9+
- [#531](https://github.com/linkedin/dustjs/pull/531) Fix whitespace in partials not being preserved (@BradEstey)
10+
- [#534](https://github.com/linkedin/dustjs/pull/534) Stringify things before calling escapeHtml on them (@sethkinast)
11+
- [#533](https://github.com/linkedin/dustjs/pull/533) Add dust.version (@sethkinast)
12+
- [#529](https://github.com/linkedin/dustjs/pull/529) Fix IE7 by removing trailing comma (@jrrbru)
13+
- [#526](https://github.com/linkedin/dustjs/pull/526) Don't stringify dust.log messages (@sethkinast)
14+
315
### v2.5.1 (2014/11/20 00:58 +00:00)
416
- [#522](https://github.com/linkedin/dustjs/pull/522) Fix the use of a multi-level object key (e.g. foo.bar) as the key for an index lookup inside non-self-closing tags. (@sethkinast)
517

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dustjs-linkedin",
3-
"version": "2.5.1",
3+
"version": "2.6.0",
44
"main": "dist/dust-full.min.js",
55
"devDependencies": {
66
"pegjs": "0.8.0"

dist/dust-core.js

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
/*! Dust - Asynchronous Templating - v2.5.1
1+
/*! Dust - Asynchronous Templating - v2.6.0
22
* http://linkedin.github.io/dustjs/
3-
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
3+
* Copyright (c) 2015 Aleksander Williams; Released under the MIT License */
44
(function(root) {
5-
var dust = {},
5+
var dust = {
6+
"version": "2.6.0"
7+
},
68
NONE = 'NONE',
79
ERROR = 'ERROR',
810
WARN = 'WARN',
@@ -18,6 +20,7 @@
1820

1921
dust.config = {
2022
whitespace: false,
23+
amd: false
2124
};
2225

2326
// Directive aliases to minify code
@@ -73,7 +76,7 @@
7376
dust.logQueue = [];
7477
}
7578
dust.logQueue.push({message: message, type: type});
76-
logger.log('[DUST ' + type + ']: ' + message);
79+
logger.log('[DUST:' + type + ']', message);
7780
}
7881
};
7982

@@ -245,14 +248,7 @@
245248
j: function(value) { return dust.escapeJs(value); },
246249
u: encodeURI,
247250
uc: encodeURIComponent,
248-
js: function(value) {
249-
if (!JSON) {
250-
dust.log('JSON is undefined. JSON stringify has not been used on [' + value + ']', WARN);
251-
return value;
252-
} else {
253-
return JSON.stringify(value);
254-
}
255-
},
251+
js: function(value) { return dust.escapeJSON(value); },
256252
jp: function(value) {
257253
if (!JSON) {dust.log('JSON is undefined. JSON parse has not been used on [' + value + ']', WARN);
258254
return value;
@@ -851,7 +847,10 @@
851847
SQUOT = /\'/g;
852848

853849
dust.escapeHtml = function(s) {
854-
if (typeof s === 'string') {
850+
if (typeof s === "string" || (s && typeof s.toString === "function")) {
851+
if (typeof s !== "string") {
852+
s = s.toString();
853+
}
855854
if (!HCHARS.test(s)) {
856855
return s;
857856
}
@@ -888,11 +887,37 @@
888887
return s;
889888
};
890889

890+
dust.escapeJSON = function(o) {
891+
if (!JSON) {
892+
dust.log('JSON is undefined. JSON stringify has not been used on [' + o + ']', WARN);
893+
return o;
894+
} else {
895+
return JSON.stringify(o)
896+
.replace(LS, '\\u2028')
897+
.replace(PS, '\\u2029')
898+
.replace(LT, '\\u003c');
899+
}
900+
};
891901

892-
if (typeof exports === 'object') {
902+
if (typeof define === "function" && define.amd && define.amd.dust === true) {
903+
define("dust.core", function() {
904+
return dust;
905+
});
906+
} else if (typeof exports === 'object') {
893907
module.exports = dust;
894908
} else {
895909
root.dust = dust;
896910
}
897911

898912
})((function(){return this;})());
913+
914+
if (typeof define === "function" && define.amd && define.amd.dust === true) {
915+
define(["require", "dust.core"], function(require, dust) {
916+
dust.onLoad = function(name, cb) {
917+
require([name], function() {
918+
cb();
919+
});
920+
};
921+
return dust;
922+
});
923+
}

dist/dust-core.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dust-full.js

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
/*! Dust - Asynchronous Templating - v2.5.1
1+
/*! Dust - Asynchronous Templating - v2.6.0
22
* http://linkedin.github.io/dustjs/
3-
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
3+
* Copyright (c) 2015 Aleksander Williams; Released under the MIT License */
44
(function(root) {
5-
var dust = {},
5+
var dust = {
6+
"version": "2.6.0"
7+
},
68
NONE = 'NONE',
79
ERROR = 'ERROR',
810
WARN = 'WARN',
@@ -18,6 +20,7 @@
1820

1921
dust.config = {
2022
whitespace: false,
23+
amd: false
2124
};
2225

2326
// Directive aliases to minify code
@@ -73,7 +76,7 @@
7376
dust.logQueue = [];
7477
}
7578
dust.logQueue.push({message: message, type: type});
76-
logger.log('[DUST ' + type + ']: ' + message);
79+
logger.log('[DUST:' + type + ']', message);
7780
}
7881
};
7982

@@ -245,14 +248,7 @@
245248
j: function(value) { return dust.escapeJs(value); },
246249
u: encodeURI,
247250
uc: encodeURIComponent,
248-
js: function(value) {
249-
if (!JSON) {
250-
dust.log('JSON is undefined. JSON stringify has not been used on [' + value + ']', WARN);
251-
return value;
252-
} else {
253-
return JSON.stringify(value);
254-
}
255-
},
251+
js: function(value) { return dust.escapeJSON(value); },
256252
jp: function(value) {
257253
if (!JSON) {dust.log('JSON is undefined. JSON parse has not been used on [' + value + ']', WARN);
258254
return value;
@@ -851,7 +847,10 @@
851847
SQUOT = /\'/g;
852848

853849
dust.escapeHtml = function(s) {
854-
if (typeof s === 'string') {
850+
if (typeof s === "string" || (s && typeof s.toString === "function")) {
851+
if (typeof s !== "string") {
852+
s = s.toString();
853+
}
855854
if (!HCHARS.test(s)) {
856855
return s;
857856
}
@@ -888,8 +887,23 @@
888887
return s;
889888
};
890889

890+
dust.escapeJSON = function(o) {
891+
if (!JSON) {
892+
dust.log('JSON is undefined. JSON stringify has not been used on [' + o + ']', WARN);
893+
return o;
894+
} else {
895+
return JSON.stringify(o)
896+
.replace(LS, '\\u2028')
897+
.replace(PS, '\\u2029')
898+
.replace(LT, '\\u003c');
899+
}
900+
};
891901

892-
if (typeof exports === 'object') {
902+
if (typeof define === "function" && define.amd && define.amd.dust === true) {
903+
define("dust.core", function() {
904+
return dust;
905+
});
906+
} else if (typeof exports === 'object') {
893907
module.exports = dust;
894908
} else {
895909
root.dust = dust;
@@ -898,7 +912,11 @@
898912
})((function(){return this;})());
899913

900914
(function(root, factory) {
901-
if (typeof exports === 'object') {
915+
if (typeof define === "function" && define.amd && define.amd.dust === true) {
916+
define("dust.parse", ["dust.core"], function(dust) {
917+
return factory(dust).parse;
918+
});
919+
} else if (typeof exports === 'object') {
902920
// in Node, require this file if we want to use the parser as a standalone module
903921
module.exports = factory(require('./dust'));
904922
// @see server file for parser methods exposed in node
@@ -3558,11 +3576,13 @@
35583576

35593577
return parser;
35603578
}));
3561-
3562-
35633579

35643580
(function(root, factory) {
3565-
if (typeof exports === 'object') {
3581+
if (typeof define === "function" && define.amd && define.amd.dust === true) {
3582+
define("dust.compile", ["dust.core", "dust.parse"], function(dust, parse) {
3583+
return factory(parse, dust).compile;
3584+
});
3585+
} else if (typeof exports === 'object') {
35663586
// in Node, require this file if we want to use the compiler as a standalone module
35673587
module.exports = factory(require('./parser').parse, require('./dust'));
35683588
} else {
@@ -3703,7 +3723,14 @@
37033723
function nullify(){}
37043724

37053725
function format(context, node) {
3706-
return dust.config.whitespace ? node : null;
3726+
if(dust.config.whitespace) {
3727+
// Format nodes are in the form ['format', eol, whitespace, line, col],
3728+
// which is unlike other nodes in that there are two pieces of content
3729+
// Join eol and whitespace together to normalize the node format
3730+
node.splice(1, 2, node.slice(1, -2).join(''));
3731+
return node;
3732+
}
3733+
return null;
37073734
}
37083735

37093736
function compile(ast, name) {
@@ -3713,16 +3740,21 @@
37133740
blocks: {},
37143741
index: 0,
37153742
auto: 'h'
3716-
};
3717-
3718-
return '(function(){dust.register(' +
3719-
(name ? '"' + name + '"' : 'null') + ',' +
3743+
},
3744+
escapedName = dust.escapeJs(name),
3745+
body_0 = 'function(dust){dust.register(' +
3746+
(name ? '"' + escapedName + '"' : 'null') + ',' +
37203747
compiler.compileNode(context, ast) +
37213748
');' +
37223749
compileBlocks(context) +
37233750
compileBodies(context) +
3724-
'return body_0;' +
3725-
'})();';
3751+
'return body_0;}';
3752+
3753+
if(dust.config.amd) {
3754+
return 'define("' + escapedName + '",["dust.core"],' + body_0 + ');';
3755+
} else {
3756+
return '(' + body_0 + ')(dust);';
3757+
}
37263758
}
37273759

37283760
function compileBlocks(context) {
@@ -3982,3 +4014,14 @@
39824014
return compiler;
39834015

39844016
}));
4017+
4018+
if (typeof define === "function" && define.amd && define.amd.dust === true) {
4019+
define(["require", "dust.core", "dust.compile"], function(require, dust) {
4020+
dust.onLoad = function(name, cb) {
4021+
require([name], function() {
4022+
cb();
4023+
});
4024+
};
4025+
return dust;
4026+
});
4027+
}

dist/dust-full.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dust.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*jshint evil:true*/
22
(function(root) {
33
var dust = {
4-
"version": "2.5.1"
4+
"version": "2.6.0"
55
},
66
NONE = 'NONE',
77
ERROR = 'ERROR',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dustjs-linkedin",
33
"title": "Dust - Asynchronous Templating",
4-
"version": "2.5.1",
4+
"version": "2.6.0",
55
"author": {
66
"name": "Aleksander Williams",
77
"url": "http://akdubya.github.com/dustjs"

0 commit comments

Comments
 (0)