mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
cleaned up template helpers
This commit is contained in:
parent
d7fbfec01e
commit
8841e43c25
17 changed files with 78 additions and 88 deletions
|
@ -4,7 +4,7 @@ define(
|
|||
[
|
||||
'sugar'
|
||||
], {
|
||||
FileSizeHelper: function (sourceSize) {
|
||||
Bytes: function (sourceSize) {
|
||||
var size = Number(sourceSize);
|
||||
return size.bytes(1);
|
||||
},
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'handlebars',
|
||||
'Shared/FormatHelpers'
|
||||
], function (Handlebars, FormatHelpers) {
|
||||
Handlebars.registerHelper('partial', function (templateName) {
|
||||
//TODO: We should be able to pass in the context, either an object or a property
|
||||
|
||||
var templateFunction = Marionette.TemplateCache.get(templateName);
|
||||
return new Handlebars.SafeString(templateFunction(this));
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('debug', function (optionalValue) {
|
||||
console.log('Current Context');
|
||||
console.log('====================');
|
||||
console.log(this);
|
||||
|
||||
if (optionalValue) {
|
||||
console.log('Value');
|
||||
console.log('====================');
|
||||
console.log(optionalValue);
|
||||
}
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('fileSize', function (size) {
|
||||
return new Handlebars.SafeString(FormatHelpers.FileSizeHelper(size));
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('date', function (date) {
|
||||
//TODO: show actual date in tooltip
|
||||
if (!date) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var shortDate = Date.create(date).short();
|
||||
var formattedDate = FormatHelpers.DateHelper(date);
|
||||
var result = '<span title="' + shortDate + '">' + formattedDate + '</span>';
|
||||
|
||||
return new Handlebars.SafeString(result);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('defaultImg', function () {
|
||||
return new Handlebars.SafeString('onerror="this.src="/content/images/poster-dark.jpg";"');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue