Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving to promises. added energy points
- Loading branch information
Showing
14 changed files
with
463 additions
and
365 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var flight = require('../lib/flight'); | ||
|
||
module.exports = function withFormUtils() { | ||
|
||
this.render = function(template, data, partials) { | ||
|
||
var renderer = function(context) { | ||
return function(text) { | ||
return template.c.compile(text, template.options).render(context, partials); | ||
}; | ||
}; | ||
|
||
var utils = { | ||
format: function() { | ||
return function(text){ | ||
var render = renderer(this); | ||
var num = (Math.round(parseFloat(render(text)) * 100) / 100).toFixed(2); | ||
var digits = num.split('.')[0]; | ||
var fraction = num.split('.')[1]; | ||
|
||
return digits.replace(/\B(?=(\d{3})+(?!\d))/g, ',') + '.' + fraction; | ||
}; | ||
}, | ||
round: function() { | ||
return function(text){ | ||
var render = renderer(this); | ||
var num = (Math.round(parseFloat(render(text)) * 100) / 100).toFixed(0); | ||
|
||
return num.replace(/\B(?=(\d{3})+(?!\d))/g, ','); | ||
}; | ||
} | ||
}; | ||
|
||
return template.render(flight.utils.merge(utils, data), partials); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.