<% /* pass in the following data structure: { className: 'top-level-class', // optional maxPerRow: 3, // optional, deafult is 4 filters: [ { className: 'filterFulfilled', // optional id: 'filterFulfilled', text: 'Fulfilled', checked: true, // This corresponds to the transaction server state(s) that the // filter is correlated with. targetState: [0, 1], attrs: { // optional happy: 'yes', jovial: 'certainly', }, }, ... ] } */ %> <% const maxPerRow = ob.maxPerRow || 4; const rows = ob.splitIntoRows(ob.filters, maxPerRow || 4); %>
<% rows.forEach(row => { %>
<% row.forEach(filter => { let attrs = ''; if (filter.attrs) { Object.keys(filter.attrs) .forEach(key => attrs += ` ${key}="${filter.attrs[key]}"`); } %>
data-state="<%= JSON.stringify(filter.targetState)%>" <%= attrs %>>
<% }); // If necessary, add in spacers. for(let i = 0; i < (maxPerRow - row.length); i++) { %>
<% } %>
<% }) %>