handlebars-helper
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -0,0 +0,0 @@ module.exports = function( grunt ){ |
@@ -1,4 +0,4 @@ | ||
/* Handlebars Helper v0.0.6 | ||
Generated on 2013-11-30 at 17:11:29 */ | ||
/* Handlebars Helper v0.0.7 | ||
Generated on 2013-12-18 at 15:30:03 */ | ||
!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.handlebarshelper=a():"undefined"!=typeof global?global.handlebarshelper=a():"undefined"!=typeof self&&(self.handlebarshelper=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){b.exports=a("./lib")},{"./lib":22}],2:[function(a,b){var c=31536e3,d=2592e3,e=86400,f=3600;b.exports=function(a){a=new Date(a);var b=Math.floor((new Date-a)/1e3),g=Math.floor(b/c);return g>1?g+" years ago":(g=Math.floor(b/d),g>1?g+" months ago":(g=Math.floor(b/e),g>1?g+" days ago":(g=Math.floor(b/f),g>1?g+" hours ago":(g=Math.floor(b/60),g>1?g+" minutes ago":Math.floor(b)<=1?"Just now":Math.floor(b)+" seconds ago"))))}},{}],3:[function(a,b){b.exports=function(a,b,c,d){if(d=d||c,"number"==typeof b){c="number"!=typeof c?void 0:c>0?c+1:c,a=a.slice(b,c);for(var e="",f=0;f<a.length;f++)e+=d.fn(a[f]);return e}}},{}],4:[function(a,b){b.exports=function(a,b,c){if("string"==typeof a)return a.search(b)>=0?c.fn():c.inverse();for(var d in a)if(a.hasOwnProperty(d)&&a[d]==b)return c.fn();return c.inverse()}},{}],5:[function(a,b){b.exports=function(a){return encodeURIComponent(a)}},{}],6:[function(a,b){b.exports=function(a,b,c,d){d=d||c,c="exact"===c?!0:!1;var e=c?a===b:a==b;return e?d.fn():d.inverse()}},{}],7:[function(a,b){b.exports=function(a,b,c){c=c||b,b="number"==typeof b?b:1;var d="",e=0;for(var f in a)if(a.hasOwnProperty(f)&&(d+=c.fn(a[f]),e++,e==b))return d}},{}],8:[function(a,b){var c=a("strftime").strftimeTZ;b.exports=function(a,b,d){d="number"==typeof d?d:null;var e=new Date(a);return c(b,e,d)}},{strftime:23}],9:[function(a,b){b.exports=function(a,b,c,d){d=d||c,c="equal"===c?!0:!1;var e=c?a>=b:a>b;return e?d.fn():d.inverse()}},{}],10:[function(a,b){b.exports=function(a,b){if(b="string"==typeof b?b:"",a.join)return a.join(b);var c="";for(var d in a)a.hasOwnProperty(d)&&(c+=a[d]+b);return c.slice(0,-b.length)}},{}],11:[function(a,b){b.exports=function(a,b,c){c=c||b,b="number"==typeof b?b:1;for(var d="",e=0;e<a.length;e++)if(d+=c.fn(a[a.length-b+e]),e+1==b)return d}},{}],12:[function(a,b){b.exports=function(a){if(a.length)return a.length;var b=0;for(var c in a)a.hasOwnProperty(c)&&b++;return b}},{}],13:[function(a,b){b.exports=function(a,b,c,d){d=d||c,c="equal"===c?!0:!1;var e=c?b>=a:b>a;return e?d.fn():d.inverse()}},{}],14:[function(a,b){b.exports=function(a){return(a||"").toLowerCase()}},{}],15:[function(a,b){b.exports=function(a,b,c,d){if(d=d||c,"number"==typeof b){var e="number"!=typeof c?void 0:b+c;a=a.slice(b,e);for(var f="",g=0;g<a.length;g++)f+=d.fn(a[g]);return f}}},{}],16:[function(a,b){b.exports=function(a,b,c){return(a||"").replace(b,c)}},{}],17:[function(a,b){b.exports=function(a,b){for(var c="",d=a.length-1;d>=0;d--)c+=b.fn(a[d]);return c}},{}],18:[function(a,b){var c=function(a){for(var b,c,d=a.length;d;)b=Math.floor(Math.random()*d--),c=a[d],a[d]=a[b],a[b]=c;return a};b.exports=function(a,b){for(var d=c(a),e="",f=0;f<d.length;f++)e+=b.fn(d[f]);return e}},{}],19:[function(a,b){b.exports=function(a,b,c){c=c||b,b="zero"===b?!0:!1;var d,e="";if(b)for(d=0;a>d;d++)e+=c.fn(d);else for(d=1;a>=d;d++)e+=c.fn(d);return e}},{}],20:[function(a,b){b.exports=function(a){return(a||"").toUpperCase()}},{}],21:[function(a,b){b.exports=function(a,b,c,d,e){e=e||d,"number"!=typeof d&&(d=1/0);for(var f=0,g="",h=0;h<a.length;h++)if(a[h][b]===c&&(g+=e.fn(a[h]),f++,f===d))return g;return g}},{}],22:[function(a,b){var c={lowercase:a("./helpers/lowercase.js"),uppercase:a("./helpers/uppercase.js"),replace:a("./helpers/replace.js"),encode:a("./helpers/encode.js"),length:a("./helpers/length.js"),contains:a("./helpers/contains.js"),first:a("./helpers/first.js"),last:a("./helpers/last.js"),between:a("./helpers/between.js"),range:a("./helpers/range.js"),where:a("./helpers/where.js"),shuffle:a("./helpers/shuffle.js"),reverse:a("./helpers/reverse.js"),join:a("./helpers/join.js"),ago:a("./helpers/ago.js"),formatDate:a("./helpers/formatDate.js"),equal:a("./helpers/equal.js"),greater:a("./helpers/greater.js"),less:a("./helpers/less.js"),times:a("./helpers/times.js")};b.exports.help=function(a){for(var b in c)a.registerHelper(b,c[b])}},{"./helpers/ago.js":2,"./helpers/between.js":3,"./helpers/contains.js":4,"./helpers/encode.js":5,"./helpers/equal.js":6,"./helpers/first.js":7,"./helpers/formatDate.js":8,"./helpers/greater.js":9,"./helpers/join.js":10,"./helpers/last.js":11,"./helpers/length.js":12,"./helpers/less.js":13,"./helpers/lowercase.js":14,"./helpers/range.js":15,"./helpers/replace.js":16,"./helpers/reverse.js":17,"./helpers/shuffle.js":18,"./helpers/times.js":19,"./helpers/uppercase.js":20,"./helpers/where.js":21}],23:[function(a,b){!function(){function a(a){return(a||"").split(" ")}function c(a,b,c){return g(a,b,c)}function d(a,b,c,d){return"number"==typeof c&&null==d&&(d=c,c=void 0),g(a,b,c,{timezone:d})}function e(a,b,c){return g(a,b,c,{utc:!0})}function f(a){return function(b,d,e){return c(b,d,a,e)}}function g(a,b,c,d){d=d||{},b&&!i(b)&&(c=b,b=void 0),b=b||new Date,c=c||o,c.formats=c.formats||{};var e=b.getTime();return(d.utc||"number"==typeof d.timezone)&&(b=h(b)),"number"==typeof d.timezone&&(b=new Date(b.getTime()+6e4*d.timezone)),a.replace(/%([-_0]?.)/g,function(a,f){var h,i;if(2==f.length){if(h=f[0],"-"==h)i="";else if("_"==h)i=" ";else{if("0"!=h)return a;i="0"}f=f[1]}switch(f){case"A":return c.days[b.getDay()];case"a":return c.shortDays[b.getDay()];case"B":return c.months[b.getMonth()];case"b":return c.shortMonths[b.getMonth()];case"C":return j(Math.floor(b.getFullYear()/100),i);case"D":return g(c.formats.D||"%m/%d/%y",b,c);case"d":return j(b.getDate(),i);case"e":return b.getDate();case"F":return g(c.formats.F||"%Y-%m-%d",b,c);case"H":return j(b.getHours(),i);case"h":return c.shortMonths[b.getMonth()];case"I":return j(k(b),i);case"j":var n=new Date(b.getFullYear(),0,1),o=Math.ceil((b.getTime()-n.getTime())/864e5);return j(o,3);case"k":return j(b.getHours(),null==i?" ":i);case"L":return j(Math.floor(e%1e3),3);case"l":return j(k(b),null==i?" ":i);case"M":return j(b.getMinutes(),i);case"m":return j(b.getMonth()+1,i);case"n":return"\n";case"o":return String(b.getDate())+l(b.getDate());case"P":return b.getHours()<12?c.am:c.pm;case"p":return b.getHours()<12?c.AM:c.PM;case"R":return g(c.formats.R||"%H:%M",b,c);case"r":return g(c.formats.r||"%I:%M:%S %p",b,c);case"S":return j(b.getSeconds(),i);case"s":return Math.floor(e/1e3);case"T":return g(c.formats.T||"%H:%M:%S",b,c);case"t":return" ";case"U":return j(m(b,"sunday"),i);case"u":var o=b.getDay();return 0==o?7:o;case"v":return g(c.formats.v||"%e-%b-%Y",b,c);case"W":return j(m(b,"monday"),i);case"w":return b.getDay();case"Y":return b.getFullYear();case"y":var n=String(b.getFullYear());return n.slice(n.length-2);case"Z":if(d.utc)return"GMT";var p=b.toString().match(/\((\w+)\)/);return p&&p[1]||"";case"z":if(d.utc)return"+0000";var q="number"==typeof d.timezone?d.timezone:-b.getTimezoneOffset();return(0>q?"-":"+")+j(Math.abs(q/60))+j(q%60);default:return f}})}function h(a){var b=6e4*(a.getTimezoneOffset()||0);return new Date(a.getTime()+b)}function i(a){var b=0,c=p.length;for(b=0;c>b;++b)if("function"!=typeof a[p[b]])return!1;return!0}function j(a,b,c){"number"==typeof b&&(c=b,b="0"),null==b&&(b="0"),c=c||2;var d=String(a);if(b)for(;d.length<c;)d=b+d;return d}function k(a){var b=a.getHours();return 0==b?b=12:b>12&&(b-=12),b}function l(a){var b=a%10,c=a%100;if(c>=11&&13>=c||0===b||b>=4)return"th";switch(b){case 1:return"st";case 2:return"nd";case 3:return"rd"}}function m(a,b){b=b||"sunday";var c=a.getDay();"monday"==b&&(0==c?c=6:c--);var d=new Date(a.getFullYear(),0,1),e=(a-d)/864e5,f=(e+7-c)/7;return Math.floor(f)}var n;n="undefined"!=typeof b?b.exports=c:function(){return this||(1,eval)("this")}();var o={days:a("Sunday Monday Tuesday Wednesday Thursday Friday Saturday"),shortDays:a("Sun Mon Tue Wed Thu Fri Sat"),months:a("January February March April May June July August September October November December"),shortMonths:a("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"),AM:"AM",PM:"PM",am:"am",pm:"pm"};n.strftime=c,n.strftimeTZ=c.strftimeTZ=d,n.strftimeUTC=c.strftimeUTC=e,n.localizedStrftime=c.localizedStrftime=f;var p=["getTime","getTimezoneOffset","getDay","getDate","getMonth","getFullYear","getYear","getHours","getMinutes","getSeconds"]}()},{}]},{},[1])(1)}); | ||
!function(a){if("function"==typeof bootstrap)bootstrap("handlebars_helper",a);else if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeHandlebarshelper=a}else"undefined"!=typeof window?window.handlebarshelper=a():global.handlebarshelper=a()}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){b.exports=a("./lib")},{"./lib":22}],2:[function(a,b){var c=a("new-date"),d=31536e3,e=2592e3,f=86400,g=3600;b.exports=function(a){a=c(a);var b=Math.floor((new Date-a)/1e3),h=Math.floor(b/d);return h>1?h+" years ago":(h=Math.floor(b/e),h>1?h+" months ago":(h=Math.floor(b/f),h>1?h+" days ago":(h=Math.floor(b/g),h>1?h+" hours ago":(h=Math.floor(b/60),h>1?h+" minutes ago":Math.floor(b)<=1?"Just now":Math.floor(b)+" seconds ago"))))}},{"new-date":23}],3:[function(a,b){b.exports=function(a,b,c,d){if(d=d||c,"number"==typeof b){c="number"!=typeof c?void 0:c>0?c+1:c,a=a.slice(b,c);for(var e="",f=0;f<a.length;f++)e+=d.fn(a[f]);return e}}},{}],4:[function(a,b){b.exports=function(a,b,c){if("string"==typeof a)return a.search(b)>=0?c.fn():c.inverse();for(var d in a)if(a.hasOwnProperty(d)&&a[d]==b)return c.fn();return c.inverse()}},{}],5:[function(a,b){b.exports=function(a){return encodeURIComponent(a)}},{}],6:[function(a,b){b.exports=function(a,b,c,d){d=d||c,c="exact"===c?!0:!1;var e=c?a===b:a==b;return e?d.fn():d.inverse()}},{}],7:[function(a,b){b.exports=function(a,b,c){c=c||b,b="number"==typeof b?b:1;var d="",e=0;for(var f in a)if(a.hasOwnProperty(f)&&(d+=c.fn(a[f]),e++,e==b))return d}},{}],8:[function(a,b){var c=a("strftime").strftimeTZ,d=a("new-date");b.exports=function(a,b,e){e="number"==typeof e?e:null;var f=d(a);return c(b,f,e)}},{"new-date":23,strftime:28}],9:[function(a,b){b.exports=function(a,b,c,d){d=d||c,c="equal"===c?!0:!1;var e=c?a>=b:a>b;return e?d.fn():d.inverse()}},{}],10:[function(a,b){b.exports=function(a,b){if(b="string"==typeof b?b:"",a.join)return a.join(b);var c="";for(var d in a)a.hasOwnProperty(d)&&(c+=a[d]+b);return c.slice(0,-b.length)}},{}],11:[function(a,b){b.exports=function(a,b,c){c=c||b,b="number"==typeof b?b:1;for(var d="",e=0;e<a.length;e++)if(d+=c.fn(a[a.length-b+e]),e+1==b)return d}},{}],12:[function(a,b){b.exports=function(a){if(a.length)return a.length;var b=0;for(var c in a)a.hasOwnProperty(c)&&b++;return b}},{}],13:[function(a,b){b.exports=function(a,b,c,d){d=d||c,c="equal"===c?!0:!1;var e=c?b>=a:b>a;return e?d.fn():d.inverse()}},{}],14:[function(a,b){b.exports=function(a){return(a||"").toLowerCase()}},{}],15:[function(a,b){b.exports=function(a,b,c,d){if(d=d||c,"number"==typeof b){var e="number"!=typeof c?void 0:b+c;a=a.slice(b,e);for(var f="",g=0;g<a.length;g++)f+=d.fn(a[g]);return f}}},{}],16:[function(a,b){b.exports=function(a,b,c){return(a||"").replace(b,c)}},{}],17:[function(a,b){b.exports=function(a,b){for(var c="",d=a.length-1;d>=0;d--)c+=b.fn(a[d]);return c}},{}],18:[function(a,b){var c=function(a){for(var b,c,d=a.length;d;)b=Math.floor(Math.random()*d--),c=a[d],a[d]=a[b],a[b]=c;return a};b.exports=function(a,b){for(var d=c(a),e="",f=0;f<d.length;f++)e+=b.fn(d[f]);return e}},{}],19:[function(a,b){b.exports=function(a,b,c){c=c||b,b="zero"===b?!0:!1;var d,e="";if(b)for(d=0;a>d;d++)e+=c.fn(d);else for(d=1;a>=d;d++)e+=c.fn(d);return e}},{}],20:[function(a,b){b.exports=function(a){return(a||"").toUpperCase()}},{}],21:[function(a,b){b.exports=function(a,b,c,d,e){e=e||d,"number"!=typeof d&&(d=1/0);for(var f=0,g="",h=0;h<a.length;h++)if(a[h][b]===c&&(g+=e.fn(a[h]),f++,f===d))return g;return g}},{}],22:[function(a,b){var c={lowercase:a("./helpers/lowercase.js"),uppercase:a("./helpers/uppercase.js"),replace:a("./helpers/replace.js"),encode:a("./helpers/encode.js"),length:a("./helpers/length.js"),contains:a("./helpers/contains.js"),first:a("./helpers/first.js"),last:a("./helpers/last.js"),between:a("./helpers/between.js"),range:a("./helpers/range.js"),where:a("./helpers/where.js"),shuffle:a("./helpers/shuffle.js"),reverse:a("./helpers/reverse.js"),join:a("./helpers/join.js"),ago:a("./helpers/ago.js"),formatDate:a("./helpers/formatDate.js"),equal:a("./helpers/equal.js"),greater:a("./helpers/greater.js"),less:a("./helpers/less.js"),times:a("./helpers/times.js")};b.exports.help=function(a){for(var b in c)a.registerHelper(b,c[b])}},{"./helpers/ago.js":2,"./helpers/between.js":3,"./helpers/contains.js":4,"./helpers/encode.js":5,"./helpers/equal.js":6,"./helpers/first.js":7,"./helpers/formatDate.js":8,"./helpers/greater.js":9,"./helpers/join.js":10,"./helpers/last.js":11,"./helpers/length.js":12,"./helpers/less.js":13,"./helpers/lowercase.js":14,"./helpers/range.js":15,"./helpers/replace.js":16,"./helpers/reverse.js":17,"./helpers/shuffle.js":18,"./helpers/times.js":19,"./helpers/uppercase.js":20,"./helpers/where.js":21}],23:[function(a,b){function c(a){return 315576e5>a?1e3*a:a}var d=a("is"),e=a("isodate"),f=a("./milliseconds"),g=a("./seconds");b.exports=function(a){return d.number(a)?new Date(c(a)):d.date(a)?new Date(a.getTime()):e.is(a)?e.parse(a):f.is(a)?f.parse(a):g.is(a)?g.parse(a):new Date(a)}},{"./milliseconds":24,"./seconds":25,is:26,isodate:27}],24:[function(a,b,c){var d=/\d{13}/;c.is=function(a){return d.test(a)},c.parse=function(a){return a=parseInt(a,10),new Date(a)}},{}],25:[function(a,b,c){var d=/\d{10}/;c.is=function(a){return d.test(a)},c.parse=function(a){var b=1e3*parseInt(a,10);return new Date(b)}},{}],26:[function(a,b){var c=Object.prototype,d=c.hasOwnProperty,e=c.toString,f=function(a){return a!==a},g={"boolean":1,number:1,string:1,undefined:1},h=b.exports={};h.a=h.type=function(a,b){return typeof a===b},h.defined=function(a){return void 0!==a},h.empty=function(a){var b,c=e.call(a);if("[object Array]"===c||"[object Arguments]"===c)return 0===a.length;if("[object Object]"===c){for(b in a)if(d.call(a,b))return!1;return!0}return"[object String]"===c?""===a:!1},h.equal=function(a,b){var c,d=e.call(a);if(d!==e.call(b))return!1;if("[object Object]"===d){for(c in a)if(!h.equal(a[c],b[c]))return!1;return!0}if("[object Array]"===d){if(c=a.length,c!==b.length)return!1;for(;--c;)if(!h.equal(a[c],b[c]))return!1;return!0}return"[object Function]"===d?a.prototype===b.prototype:"[object Date]"===d?a.getTime()===b.getTime():a===b},h.hosted=function(a,b){var c=typeof b[a];return"object"===c?!!b[a]:!g[c]},h.instance=h["instanceof"]=function(a,b){return a instanceof b},h["null"]=function(a){return null===a},h.undefined=function(a){return void 0===a},h.arguments=function(a){var b="[object Arguments]"===e.call(a),c=!h.array(a)&&h.arraylike(a)&&h.object(a)&&h.fn(a.callee);return b||c},h.array=function(a){return"[object Array]"===e.call(a)},h.arguments.empty=function(a){return h.arguments(a)&&0===a.length},h.array.empty=function(a){return h.array(a)&&0===a.length},h.arraylike=function(a){return!!a&&!h.boolean(a)&&d.call(a,"length")&&isFinite(a.length)&&h.number(a.length)&&a.length>=0},h.boolean=function(a){return"[object Boolean]"===e.call(a)},h["false"]=function(a){return h.boolean(a)&&(a===!1||a.valueOf()===!1)},h["true"]=function(a){return h.boolean(a)&&(a===!0||a.valueOf()===!0)},h.date=function(a){return"[object Date]"===e.call(a)},h.element=function(a){return void 0!==a&&"undefined"!=typeof HTMLElement&&a instanceof HTMLElement&&1===a.nodeType},h.error=function(a){return"[object Error]"===e.call(a)},h.fn=h["function"]=function(a){var b="undefined"!=typeof window&&a===window.alert;return b||"[object Function]"===e.call(a)},h.number=function(a){return"[object Number]"===e.call(a)},h.infinite=function(a){return 1/0===a||a===-1/0},h.decimal=function(a){return h.number(a)&&!f(a)&&0!==a%1},h.divisibleBy=function(a,b){var c=h.infinite(a),d=h.infinite(b),e=h.number(a)&&!f(a)&&h.number(b)&&!f(b)&&0!==b;return c||d||e&&0===a%b},h.int=function(a){return h.number(a)&&!f(a)&&0===a%1},h.maximum=function(a,b){if(f(a))throw new TypeError("NaN is not a valid value");if(!h.arraylike(b))throw new TypeError("second argument must be array-like");for(var c=b.length;--c>=0;)if(a<b[c])return!1;return!0},h.minimum=function(a,b){if(f(a))throw new TypeError("NaN is not a valid value");if(!h.arraylike(b))throw new TypeError("second argument must be array-like");for(var c=b.length;--c>=0;)if(a>b[c])return!1;return!0},h.nan=function(a){return!h.number(a)||a!==a},h.even=function(a){return h.infinite(a)||h.number(a)&&a===a&&0===a%2},h.odd=function(a){return h.infinite(a)||h.number(a)&&a===a&&0!==a%2},h.ge=function(a,b){if(f(a)||f(b))throw new TypeError("NaN is not a valid value");return!h.infinite(a)&&!h.infinite(b)&&a>=b},h.gt=function(a,b){if(f(a)||f(b))throw new TypeError("NaN is not a valid value");return!h.infinite(a)&&!h.infinite(b)&&a>b},h.le=function(a,b){if(f(a)||f(b))throw new TypeError("NaN is not a valid value");return!h.infinite(a)&&!h.infinite(b)&&b>=a},h.lt=function(a,b){if(f(a)||f(b))throw new TypeError("NaN is not a valid value");return!h.infinite(a)&&!h.infinite(b)&&b>a},h.within=function(a,b,c){if(f(a)||f(b)||f(c))throw new TypeError("NaN is not a valid value");if(!h.number(a)||!h.number(b)||!h.number(c))throw new TypeError("all arguments must be numbers");var d=h.infinite(a)||h.infinite(b)||h.infinite(c);return d||a>=b&&c>=a},h.object=function(a){return a&&"[object Object]"===e.call(a)},h.hash=function(a){return h.object(a)&&a.constructor===Object&&!a.nodeType&&!a.setInterval},h.regexp=function(a){return"[object RegExp]"===e.call(a)},h.string=function(a){return"[object String]"===e.call(a)}},{}],27:[function(a,b,c){var d=/^(\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:([ T])(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;c.parse=function(a){var b=[1,5,6,7,8,11,12],c=d.exec(a),e=0;if(!c)return new Date(a);for(var f,g=0;f=b[g];g++)c[f]=parseInt(c[f],10)||0;c[2]=parseInt(c[2],10)||1,c[3]=parseInt(c[3],10)||1,c[2]--,c[8]&&(c[8]=(c[8]+"00").substring(0,3))," "==c[4]?e=(new Date).getTimezoneOffset():"Z"!==c[9]&&c[10]&&(e=60*c[11]+c[12],"+"==c[10]&&(e=0-e));var h=Date.UTC(c[1],c[2],c[3],c[5],c[6]+e,c[7],c[8]);return new Date(h)},c.is=function(a,b){return b&&!1===/^\d{4}-\d{2}-\d{2}/.test(a)?!1:d.test(a)}},{}],28:[function(a,b){!function(){function a(a){return(a||"").split(" ")}function c(a,b,c){return g(a,b,c)}function d(a,b,c,d){return"number"==typeof c&&null==d&&(d=c,c=void 0),g(a,b,c,{timezone:d})}function e(a,b,c){return g(a,b,c,{utc:!0})}function f(a){return function(b,d,e){return c(b,d,a,e)}}function g(a,b,c,d){d=d||{},b&&!i(b)&&(c=b,b=void 0),b=b||new Date,c=c||o,c.formats=c.formats||{};var e=b.getTime();return(d.utc||"number"==typeof d.timezone)&&(b=h(b)),"number"==typeof d.timezone&&(b=new Date(b.getTime()+6e4*d.timezone)),a.replace(/%([-_0]?.)/g,function(a,f){var h,i;if(2==f.length){if(h=f[0],"-"==h)i="";else if("_"==h)i=" ";else{if("0"!=h)return a;i="0"}f=f[1]}switch(f){case"A":return c.days[b.getDay()];case"a":return c.shortDays[b.getDay()];case"B":return c.months[b.getMonth()];case"b":return c.shortMonths[b.getMonth()];case"C":return j(Math.floor(b.getFullYear()/100),i);case"D":return g(c.formats.D||"%m/%d/%y",b,c);case"d":return j(b.getDate(),i);case"e":return b.getDate();case"F":return g(c.formats.F||"%Y-%m-%d",b,c);case"H":return j(b.getHours(),i);case"h":return c.shortMonths[b.getMonth()];case"I":return j(k(b),i);case"j":var n=new Date(b.getFullYear(),0,1),o=Math.ceil((b.getTime()-n.getTime())/864e5);return j(o,3);case"k":return j(b.getHours(),null==i?" ":i);case"L":return j(Math.floor(e%1e3),3);case"l":return j(k(b),null==i?" ":i);case"M":return j(b.getMinutes(),i);case"m":return j(b.getMonth()+1,i);case"n":return"\n";case"o":return String(b.getDate())+l(b.getDate());case"P":return b.getHours()<12?c.am:c.pm;case"p":return b.getHours()<12?c.AM:c.PM;case"R":return g(c.formats.R||"%H:%M",b,c);case"r":return g(c.formats.r||"%I:%M:%S %p",b,c);case"S":return j(b.getSeconds(),i);case"s":return Math.floor(e/1e3);case"T":return g(c.formats.T||"%H:%M:%S",b,c);case"t":return" ";case"U":return j(m(b,"sunday"),i);case"u":var o=b.getDay();return 0==o?7:o;case"v":return g(c.formats.v||"%e-%b-%Y",b,c);case"W":return j(m(b,"monday"),i);case"w":return b.getDay();case"Y":return b.getFullYear();case"y":var n=String(b.getFullYear());return n.slice(n.length-2);case"Z":if(d.utc)return"GMT";var p=b.toString().match(/\((\w+)\)/);return p&&p[1]||"";case"z":if(d.utc)return"+0000";var q="number"==typeof d.timezone?d.timezone:-b.getTimezoneOffset();return(0>q?"-":"+")+j(Math.abs(q/60))+j(q%60);default:return f}})}function h(a){var b=6e4*(a.getTimezoneOffset()||0);return new Date(a.getTime()+b)}function i(a){var b=0,c=p.length;for(b=0;c>b;++b)if("function"!=typeof a[p[b]])return!1;return!0}function j(a,b,c){"number"==typeof b&&(c=b,b="0"),null==b&&(b="0"),c=c||2;var d=String(a);if(b)for(;d.length<c;)d=b+d;return d}function k(a){var b=a.getHours();return 0==b?b=12:b>12&&(b-=12),b}function l(a){var b=a%10,c=a%100;if(c>=11&&13>=c||0===b||b>=4)return"th";switch(b){case 1:return"st";case 2:return"nd";case 3:return"rd"}}function m(a,b){b=b||"sunday";var c=a.getDay();"monday"==b&&(0==c?c=6:c--);var d=new Date(a.getFullYear(),0,1),e=(a-d)/864e5,f=(e+7-c)/7;return Math.floor(f)}var n;n="undefined"!=typeof b?b.exports=c:function(){return this||(1,eval)("this")}();var o={days:a("Sunday Monday Tuesday Wednesday Thursday Friday Saturday"),shortDays:a("Sun Mon Tue Wed Thu Fri Sat"),months:a("January February March April May June July August September October November December"),shortMonths:a("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"),AM:"AM",PM:"PM",am:"am",pm:"pm"};n.strftime=c,n.strftimeTZ=c.strftimeTZ=d,n.strftimeUTC=c.strftimeUTC=e,n.localizedStrftime=c.localizedStrftime=f;var p=["getTime","getTimezoneOffset","getDay","getDate","getMonth","getFullYear","getYear","getHours","getMinutes","getSeconds"]}()},{}]},{},[1])(1)}); |
@@ -0,1 +1,6 @@ | ||
### 0.0.7 | ||
*December 18, 2013* | ||
- `ago` and `formatDate` helpers now work with unix timestamps as strings | ||
### 0.0.6 | ||
@@ -2,0 +7,0 @@ *November 30, 2013* |
// Modified form of `timeago` helper from https://github.com/assemble/handlebars-helpers | ||
var newDate = require('new-date'); | ||
var YEAR = 60 * 60 * 24 * 365; | ||
@@ -8,3 +11,3 @@ var MONTH = 60 * 60 * 24 * 30; | ||
module.exports = function( date ){ | ||
date = new Date( date ); | ||
date = newDate( date ); | ||
var seconds = Math.floor( ( new Date() - date ) / 1000 ); | ||
@@ -11,0 +14,0 @@ var interval = Math.floor( seconds / YEAR ); |
@@ -0,0 +0,0 @@ module.exports = function( collection, start, end, options ){ |
@@ -0,0 +0,0 @@ module.exports = function( collection, item, options ){ |
module.exports = function( string ){ | ||
return encodeURIComponent( string ); | ||
}; |
@@ -0,0 +0,0 @@ module.exports = function( left, right, exact, options ){ |
@@ -0,0 +0,0 @@ module.exports = function( collection, count, options ){ |
var strftimeTZ = require('strftime').strftimeTZ; | ||
var newDate = require('new-date'); | ||
module.exports = function( date_string, format, offset ){ | ||
offset = ( typeof offset === 'number' ) ? offset : null; | ||
var date = new Date( date_string ); | ||
var date = newDate( date_string ); | ||
return strftimeTZ( format, date, offset ); | ||
}; |
@@ -0,0 +0,0 @@ module.exports = function( left, right, equal, options ){ |
@@ -0,0 +0,0 @@ module.exports = function( collection, separator ){ |
@@ -0,0 +0,0 @@ module.exports = function( collection, count, options ){ |
@@ -0,0 +0,0 @@ module.exports = function( collection ){ |
@@ -0,0 +0,0 @@ module.exports = function( left, right, equal, options ){ |
module.exports = function( string ){ | ||
return ( string || '' ).toLowerCase(); | ||
}; |
@@ -0,0 +0,0 @@ module.exports = function( collection, start, amount, options ){ |
module.exports = function( string, to_replace, replacement ){ | ||
return ( string || '' ).replace( to_replace, replacement ); | ||
}; |
@@ -0,0 +0,0 @@ module.exports = function( collection, options ){ |
@@ -0,0 +0,0 @@ // Simple shuffling method based off of http://bost.ocks.org/mike/shuffle/ |
@@ -0,0 +0,0 @@ module.exports = function( number, zero, options ){ |
module.exports = function( string ){ | ||
return ( string || '' ).toUpperCase(); | ||
}; |
@@ -0,0 +0,0 @@ module.exports = function( collection, key, value, limit, options ){ |
@@ -0,0 +0,0 @@ var helpers = { |
@@ -0,0 +0,0 @@ Copyright (c) 2013 Sparkart Group, Inc. |
{ | ||
"name": "handlebars-helper", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A collection of helpers for quick and tasty Handlebars templates", | ||
@@ -34,3 +34,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"strftime": "~0.7.0" | ||
"strftime": "~0.7.0", | ||
"new-date": "~0.2.0" | ||
}, | ||
@@ -37,0 +38,0 @@ "testling": { |
@@ -0,0 +0,0 @@ # Handlebars Helper |
@@ -190,3 +190,3 @@ var assert = require('assert'); | ||
test( 'ago', function( t ){ | ||
t.plan(7); | ||
t.plan(8); | ||
var now = new Date; | ||
@@ -206,7 +206,8 @@ var seconds_ago = new Date( now - SECOND * 30 ); | ||
t.ok( tpl( months_ago ) === '6 months ago', 'renders "6 months ago" for a date 6 months in the past' ); | ||
t.ok( tpl( year_ago ) === '2 years ago', 'renders "2 years ago" for a date 1 year in the past' ); | ||
t.ok( tpl( year_ago ) === '2 years ago', 'renders "2 years ago" for a date 2 years in the past' ); | ||
t.ok( tpl( year_ago.getTime().toString() ) === '2 years ago', 'renders "2 years ago" for a date 2 years in the past (string)' ); | ||
}); | ||
test( 'formatDate', function( t ){ | ||
t.plan(5); | ||
t.plan(6); | ||
var dates = [ | ||
@@ -216,3 +217,4 @@ '2013-09-30T15:00:00.340Z', | ||
'Mon Sep 30 2013 15:00:00 GMT-0700 (PDT)', | ||
1380578400000 | ||
1380578400000, | ||
'1380578400000' | ||
]; | ||
@@ -229,2 +231,3 @@ var tpl = Handlebars.compile('{{formatDate this "%A, %B %o %Y"}}'); | ||
t.ok( tpl5( dates[3] ) === '30-Sep-2013', 'date successfully formatted' ); | ||
t.ok( tpl5( dates[4] ) === '30-Sep-2013', 'date successfully formatted' ); | ||
}); | ||
@@ -231,0 +234,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
427237
11503
2
8
+ Addednew-date@~0.2.0
+ Addedis@0.2.6(transitive)
+ Addednew-date@0.2.0(transitive)