Added sprintf.

Rotation tooltips updated in realtime with current rotation degree.
This commit is contained in:
Gunther Brunner
2014-05-20 18:28:51 +09:00
parent 3143101ab5
commit e405ca1577
6 changed files with 97 additions and 16 deletions

View File

@@ -0,0 +1,2 @@
module.exports = angular.module('stf.sprintf', [])
.filter('sprintf', require('./sprintf-filter'))

View File

@@ -0,0 +1,14 @@
module.exports = function sprintfFilter() {
function parse(str) {
var args = [].slice.call(arguments, 1)
var i = 0
return str.replace(/%s/g, function () {
return args[i++]
})
}
return function (input) {
return parse(input, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5])
}
}

View File

@@ -0,0 +1,13 @@
describe('sprintf', function() {
beforeEach(module('stf.sprintf'));
it('should ...', inject(function($filter) {
var filter = $filter('sprintf');
expect(filter('input')).toEqual('output');
}));
});