X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Ftemplate-helper.js;h=16a14cc4c3d0bdfd42406a03ef29d31f698eddaa;hb=a81f229bb12fab13a23db4423e24de2357b81e70;hp=deb3a37fc183a4af3cecdea6dda250d4d8193bab;hpb=5690ad318ed98cff45bf1fd192656a7156c7045c;p=squeep-html-template-helper diff --git a/lib/template-helper.js b/lib/template-helper.js index deb3a37..16a14cc 100644 --- a/lib/template-helper.js +++ b/lib/template-helper.js @@ -4,7 +4,7 @@ * A bunch of shorthand to put together common parts of an HTML page. */ -const { lazy } = require('@squeep/lazy'); +const { lazy } = require('@squeep/lazy-property'); /** * Some fields may have values outside normal dates, handle them here. @@ -93,6 +93,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 @@ -363,6 +374,7 @@ module.exports = { htmlHeader, htmlFooter, htmlMessages, + indented, renderNavLink, LI, UL,