add indention helper
[squeep-html-template-helper] / lib / template-helper.js
index a20d1aec13721cfda098ef7514df175422f51dfa..16a14cc4c3d0bdfd42406a03ef29d31f698eddaa 100644 (file)
@@ -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 <head> 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,