<%= val.label %>
<% if (val.type ==='dropdown') { %>
<% } else if (val.type ==='radio') { %>
<%
// if any options has a checked value, check the first one. Otherwise use the first default.
let checkedIndex = val.options.findIndex(opt => opt.checked);
checkedIndex = checkedIndex === -1 ? val.options.findIndex(opt => opt.default) : checkedIndex;
_.each(val.options, function(option, ind) {
%>
<%
const checked = checkedIndex === ind ? 'checked' : '';
var parsedLabel = ob.parseEmojis(option.label);
print(``);
print(``);
%>
<% }); %>
<% } else if (val.type ==='checkbox') { %>
<%
const anyChecked = val.options.filter(opt => opt.checked);
val.options.forEach((option, index) => {
let checked = '';
// if none of the checkboxes have a checked value, use the default values
if (option.checked || !anyChecked.length && option.default) {
checked = 'checked';
}
var parsedLabel = ob.parseEmojis(option.label);
print(``);
print(``);
});
%>
<% } %>