cleaned up template helpers

This commit is contained in:
kay.one 2013-06-24 21:43:16 -07:00
commit 8841e43c25
17 changed files with 78 additions and 88 deletions

View file

@ -1,18 +1,17 @@
'use strict';
define(
[
'handlebars',
'sugar'
], {
register: function (handlebars) {
handlebars.registerHelper('ShortDate', function (input) {
if (!input) {
return '';
}
], function (Handlebars) {
Handlebars.registerHelper('ShortDate', function (input) {
if (!input) {
return '';
}
var date = Date.create(input);
var result = '<span title="' + date.full() + '">' + date.short() + '</span>';
var date = Date.create(input);
var result = '<span title="' + date.full() + '">' + date.short() + '</span>';
return new handlebars.SafeString(result);
});
}
return new Handlebars.SafeString(result);
});
});

View file

@ -0,0 +1,10 @@
'use strict';
define(
[
'handlebars'
], function (Handlebars) {
Handlebars.registerHelper('defaultImg', function () {
return new Handlebars.SafeString('onerror="this.src="/content/images/poster-dark.jpg";"');
});
});

View file

@ -0,0 +1,10 @@
'use strict';
define(
[
'handlebars',
'Shared/FormatHelpers'
], function (Handlebars, FormatHelpers) {
Handlebars.registerHelper('Bytes', function (size) {
return new Handlebars.SafeString(FormatHelpers.Bytes(size));
});
});

View file

@ -1,8 +1,11 @@
'use strict';
'use strict';
define(
[
'templates'
'templates',
'Handlebars/Helpers/DateTime',
'Handlebars/Helpers/Html',
'Handlebars/Helpers/Numbers',
'Handlebars/Debug'
], function (Templates) {
return function () {
this.get = function (templateId) {

18
UI/Handlebars/debug.js Normal file
View file

@ -0,0 +1,18 @@
'use strict';
define({
register: function (Handlebars) {
Handlebars.registerHelper("debug", function (optionalValue) {
console.group('Handlebar context');
console.log(this);
if (optionalValue) {
console.group('optional values');
console.log('optinal values');
console.groupEnd();
}
console.groupEnd();
});
}
});