Skip to content

Commit c0daff0

Browse files
author
Prayrit Jain
committed
Release v1.3.0
1 parent 9984165 commit c0daff0

6 files changed

+31
-31
lines changed

archive/dustjs-helpers-1.3.0.tar.gz

7.71 KB
Binary file not shown.

archive/dustjs-helpers-1.3.0.zip

8.26 KB
Binary file not shown.

dist/dust-helpers.js

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
/*! dustjs-helpers - v1.2.0
1+
/*! dustjs-helpers - v1.3.0
22
* https://github.com/linkedin/dustjs-helpers
33
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
44
(function(dust){
55

6-
// Note: all error conditions are logged to console and failed silently
7-
8-
/* make a safe version of console if it is not available
9-
* currently supporting:
10-
* _console.log
11-
* */
12-
var _console = (typeof console !== 'undefined')? console: {
13-
log: function(){
14-
/* a noop*/
15-
}
16-
};
6+
//using the built in logging method of dust when accessible
7+
var _log = dust.log ? function(mssg) { dust.log(mssg, "INFO"); } : function() {};
178

189
function isSelect(context) {
1910
var value = context.current();
@@ -57,7 +48,7 @@ function filter(chunk, context, bodies, params, filterOp) {
5748
}
5849
}
5950
else {
60-
_console.log ("No key specified for filter in:" + filterOpType + " helper ");
51+
_log("No key specified for filter in:" + filterOpType + " helper ");
6152
return chunk;
6253
}
6354
expectedValue = dust.helpers.tap(params.value, chunk, context);
@@ -71,7 +62,7 @@ function filter(chunk, context, bodies, params, filterOp) {
7162
return chunk.render(body, context);
7263
}
7364
else {
74-
_console.log( "Missing body block in the " + filterOpType + " helper ");
65+
_log("No key specified for filter in:" + filterOpType + " helper ");
7566
return chunk;
7667
}
7768
}
@@ -191,7 +182,7 @@ var helpers = {
191182
dump = JSON.stringify(context.stack.head, jsonFilter, 2);
192183
}
193184
if (to === 'console') {
194-
_console.log(dump);
185+
_log(dump);
195186
return chunk;
196187
}
197188
else {
@@ -226,7 +217,7 @@ var helpers = {
226217
return chunk.render( bodies.block, context );
227218
}
228219
else {
229-
_console.log( "Missing body block in the if helper!" );
220+
_log("Missing body block in the if helper!");
230221
return chunk;
231222
}
232223
}
@@ -236,7 +227,7 @@ var helpers = {
236227
}
237228
// no condition
238229
else {
239-
_console.log( "No condition given in the if helper!" );
230+
_log("No condition given in the if helper!");
240231
}
241232
return chunk;
242233
},
@@ -257,14 +248,17 @@ var helpers = {
257248
operand = params.operand,
258249
round = params.round,
259250
mathOut = null,
260-
operError = function(){_console.log("operand is required for this math method"); return null;};
251+
operError = function(){
252+
_log("operand is required for this math method");
253+
return null;
254+
};
261255
key = dust.helpers.tap(key, chunk, context);
262256
operand = dust.helpers.tap(operand, chunk, context);
263257
// TODO: handle and tests for negatives and floats in all math operations
264258
switch(method) {
265259
case "mod":
266260
if(operand === 0 || operand === -0) {
267-
_console.log("operand for divide operation is 0/-0: expect Nan!");
261+
_log("operand for divide operation is 0/-0: expect Nan!");
268262
}
269263
mathOut = parseFloat(key) % parseFloat(operand);
270264
break;
@@ -279,7 +273,7 @@ var helpers = {
279273
break;
280274
case "divide":
281275
if(operand === 0 || operand === -0) {
282-
_console.log("operand for divide operation is 0/-0: expect Nan/Infinity!");
276+
_log("operand for divide operation is 0/-0: expect Nan/Infinity!");
283277
}
284278
mathOut = parseFloat(key) / parseFloat(operand);
285279
break;
@@ -296,7 +290,7 @@ var helpers = {
296290
mathOut = Math.abs(parseFloat(key));
297291
break;
298292
default:
299-
_console.log( "method passed is not supported" );
293+
_log("method passed is not supported");
300294
}
301295

302296
if (mathOut !== null){
@@ -317,7 +311,7 @@ var helpers = {
317311
}
318312
// no key parameter and no method
319313
else {
320-
_console.log( "Key is a required parameter for math helper along with method/operand!" );
314+
_log("Key is a required parameter for math helper along with method/operand!");
321315
}
322316
return chunk;
323317
},
@@ -340,13 +334,13 @@ var helpers = {
340334
return chunk.render(bodies.block, context.push({ isSelect: true, isResolved: false, selectKey: key }));
341335
}
342336
else {
343-
_console.log( "Missing body block in the select helper ");
337+
_log("Missing body block in the select helper ");
344338
return chunk;
345339
}
346340
}
347341
// no key
348342
else {
349-
_console.log( "No key given in the select helper!" );
343+
_log("No key given in the select helper!");
350344
}
351345
return chunk;
352346
},
@@ -512,6 +506,12 @@ var helpers = {
512506

513507
};
514508

515-
dust.helpers = helpers;
509+
for (var key in helpers) {
510+
dust.helpers[key] = helpers[key];
511+
}
512+
513+
if(typeof exports !== 'undefined') {
514+
module.exports = dust;
515+
}
516516

517-
})(typeof exports !== 'undefined' ? module.exports = require('dustjs-linkedin') : dust);
517+
})(typeof exports !== 'undefined' ? require('dustjs-linkedin') : dust);

dist/dust-helpers.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gruntfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module.exports = function (grunt) {
116116
thresholds: {
117117
lines: 90,
118118
statements: 90,
119-
branches: 85,
119+
branches: 80,
120120
functions: 80
121121
}
122122
}
@@ -280,4 +280,4 @@ module.exports = function (grunt) {
280280

281281
//default task - full test
282282
grunt.registerTask('default', ['test']);
283-
};
283+
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dustjs-helpers",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"author": {
55
"name": "Aleksander Williams",
66
"url": "http://akdubya.github.com/dustjs"

0 commit comments

Comments
 (0)