Skip to content

Commit

Permalink
Release v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Prayrit Jain committed Sep 9, 2014
1 parent 9984165 commit c0daff0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
Binary file added archive/dustjs-helpers-1.3.0.tar.gz
Binary file not shown.
Binary file added archive/dustjs-helpers-1.3.0.zip
Binary file not shown.
52 changes: 26 additions & 26 deletions dist/dust-helpers.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
/*! dustjs-helpers - v1.2.0
/*! dustjs-helpers - v1.3.0
* https://github.com/linkedin/dustjs-helpers
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
(function(dust){

// Note: all error conditions are logged to console and failed silently

/* make a safe version of console if it is not available
* currently supporting:
* _console.log
* */
var _console = (typeof console !== 'undefined')? console: {
log: function(){
/* a noop*/
}
};
//using the built in logging method of dust when accessible
var _log = dust.log ? function(mssg) { dust.log(mssg, "INFO"); } : function() {};

function isSelect(context) {
var value = context.current();
Expand Down Expand Up @@ -57,7 +48,7 @@ function filter(chunk, context, bodies, params, filterOp) {
}
}
else {
_console.log ("No key specified for filter in:" + filterOpType + " helper ");
_log("No key specified for filter in:" + filterOpType + " helper ");
return chunk;
}
expectedValue = dust.helpers.tap(params.value, chunk, context);
Expand All @@ -71,7 +62,7 @@ function filter(chunk, context, bodies, params, filterOp) {
return chunk.render(body, context);
}
else {
_console.log( "Missing body block in the " + filterOpType + " helper ");
_log("No key specified for filter in:" + filterOpType + " helper ");
return chunk;
}
}
Expand Down Expand Up @@ -191,7 +182,7 @@ var helpers = {
dump = JSON.stringify(context.stack.head, jsonFilter, 2);
}
if (to === 'console') {
_console.log(dump);
_log(dump);
return chunk;
}
else {
Expand Down Expand Up @@ -226,7 +217,7 @@ var helpers = {
return chunk.render( bodies.block, context );
}
else {
_console.log( "Missing body block in the if helper!" );
_log("Missing body block in the if helper!");
return chunk;
}
}
Expand All @@ -236,7 +227,7 @@ var helpers = {
}
// no condition
else {
_console.log( "No condition given in the if helper!" );
_log("No condition given in the if helper!");
}
return chunk;
},
Expand All @@ -257,14 +248,17 @@ var helpers = {
operand = params.operand,
round = params.round,
mathOut = null,
operError = function(){_console.log("operand is required for this math method"); return null;};
operError = function(){
_log("operand is required for this math method");
return null;
};
key = dust.helpers.tap(key, chunk, context);
operand = dust.helpers.tap(operand, chunk, context);
// TODO: handle and tests for negatives and floats in all math operations
switch(method) {
case "mod":
if(operand === 0 || operand === -0) {
_console.log("operand for divide operation is 0/-0: expect Nan!");
_log("operand for divide operation is 0/-0: expect Nan!");
}
mathOut = parseFloat(key) % parseFloat(operand);
break;
Expand All @@ -279,7 +273,7 @@ var helpers = {
break;
case "divide":
if(operand === 0 || operand === -0) {
_console.log("operand for divide operation is 0/-0: expect Nan/Infinity!");
_log("operand for divide operation is 0/-0: expect Nan/Infinity!");
}
mathOut = parseFloat(key) / parseFloat(operand);
break;
Expand All @@ -296,7 +290,7 @@ var helpers = {
mathOut = Math.abs(parseFloat(key));
break;
default:
_console.log( "method passed is not supported" );
_log("method passed is not supported");
}

if (mathOut !== null){
Expand All @@ -317,7 +311,7 @@ var helpers = {
}
// no key parameter and no method
else {
_console.log( "Key is a required parameter for math helper along with method/operand!" );
_log("Key is a required parameter for math helper along with method/operand!");
}
return chunk;
},
Expand All @@ -340,13 +334,13 @@ var helpers = {
return chunk.render(bodies.block, context.push({ isSelect: true, isResolved: false, selectKey: key }));
}
else {
_console.log( "Missing body block in the select helper ");
_log("Missing body block in the select helper ");
return chunk;
}
}
// no key
else {
_console.log( "No key given in the select helper!" );
_log("No key given in the select helper!");
}
return chunk;
},
Expand Down Expand Up @@ -512,6 +506,12 @@ var helpers = {

};

dust.helpers = helpers;
for (var key in helpers) {
dust.helpers[key] = helpers[key];
}

if(typeof exports !== 'undefined') {
module.exports = dust;
}

})(typeof exports !== 'undefined' ? module.exports = require('dustjs-linkedin') : dust);
})(typeof exports !== 'undefined' ? require('dustjs-linkedin') : dust);
4 changes: 2 additions & 2 deletions dist/dust-helpers.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = function (grunt) {
thresholds: {
lines: 90,
statements: 90,
branches: 85,
branches: 80,
functions: 80
}
}
Expand Down Expand Up @@ -280,4 +280,4 @@ module.exports = function (grunt) {

//default task - full test
grunt.registerTask('default', ['test']);
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dustjs-helpers",
"version": "1.2.0",
"version": "1.3.0",
"author": {
"name": "Aleksander Williams",
"url": "http://akdubya.github.com/dustjs"
Expand Down

0 comments on commit c0daff0

Please sign in to comment.