szurubooru/client/js/util/handlebars-helpers.js

24 lines
671 B
JavaScript
Raw Normal View History

2016-04-05 17:57:26 +02:00
'use strict';
const handlebars = require('handlebars');
const misc = require('./misc.js');
2016-04-06 22:34:21 +02:00
handlebars.registerHelper('reltime', function(time) {
2016-04-05 17:57:26 +02:00
return new handlebars.SafeString(
2016-04-06 22:34:21 +02:00
'<time datetime="' + time + '" title="' + time + '">' +
misc.formatRelativeTime(time) +
2016-04-05 17:57:26 +02:00
'</time>');
});
2016-04-06 22:34:21 +02:00
handlebars.registerHelper('thumbnail', function(url) {
return new handlebars.SafeString(
'<div class="thumbnail" ' +
'style="background-image: url(\'' + url + '\')">' +
'<img alt="thumbnail" src="' + url + '"/>' +
'</div>');
});
2016-04-06 22:34:21 +02:00
handlebars.registerHelper('toLowerCase', function(str) {
return str.toLowerCase();
});