% // buttons is provided to this template const numCols = (buttons && buttons.COLS && buttons.COLS.length) || 1; const colWidth = (12 / numCols) >= 1 ? Math.floor(12 / numCols) : null; // chunk the flat ROWS array into logical rows of numCols items const chunks = []; for (let i = 0; i < (buttons.ROWS || []).length; i += numCols) { chunks.push((buttons.ROWS || []).slice(i, i + numCols)); } %>