X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Ftemplate-helper.js;h=c983e80acd44329fc6c516ee874198fc2d2e6e58;hb=826ef55e1f8506012d627294c8225cf8b01a5a69;hp=a20d1aec13721cfda098ef7514df175422f51dfa;hpb=e2c0fe7d1ab89eb892cad2f9003391c2e41010e7;p=squeep-html-template-helper diff --git a/lib/template-helper.js b/lib/template-helper.js index a20d1ae..c983e80 100644 --- a/lib/template-helper.js +++ b/lib/template-helper.js @@ -65,6 +65,33 @@ lazy(dateFormat, '_dtf', () => { }); +/** + * Wrap a Date in a ', + ].join(''); +} + + /** * Render a duration. * @param {Number} seconds @@ -93,6 +120,17 @@ const secondsToPeriod = (seconds) => { }; +/** + * Return array of strings prefixed with tabs. + * @param {Number} indent + * @param {String[]} list + */ +const indented = (indent, list) => { + const spacer = '\t'.repeat(indent); + return list.map((l) => `${spacer}${l}`); +}; + + /** * Render the preamble for an HTML page. * @param {Number} pagePathLevel number of paths below root this page is @@ -356,6 +394,7 @@ function htmlPage(pagePathLevel, ctx, options, main = []) { module.exports = { dateOrNot, dateFormat, + timeElement, secondsToPeriod, htmlHead, htmlBody, @@ -363,6 +402,7 @@ module.exports = { htmlHeader, htmlFooter, htmlMessages, + indented, renderNavLink, LI, UL,