LHJ

I'm a FE developer.

ejs locals 변수 삼항연산자로 기본값 설정

07 Dec 2020 » ejs

ejs locals 변수 삼항연산자로 기본값 설정

<div class="sort">
<% for (var name in locals) { %>
    <% locals[name].forEach(function (value, index, array) { %>
        <% if (index + 1 !== array.length) { %>
            <span class="txt"><%- value %></span>
            <span class="bar"></span>
        <% } else { %>
            <button type="button" class="btn btn_order"><span class="txt"><%- value %></span></button>
        <% } %>
    <% }) %>
<% } %>
</div>
<% for(var i = 0; i < radioInfo.length; i++){ %>
<div class="bx_radio">
  <% if(i === 0){ %>
    <%# [input] checked _%>
    <input type="radio" name="<%- locals.name ? locals.name : "radio" %>" id="<%- radioInfo[i].radioId ? radioInfo[i].radioId : "radio" + i %>" class="radio" checked>
  <% } else { %>
    <%# [input] not checked _%>
    <input type="radio" name="<%- locals.name ? locals.name : "radio" %>" id="<%- radioInfo[i].radioId ? radioInfo[i].radioId : "radio" + i %>" class="radio">
  <% } %>
  <label for="<%- radioInfo[i].radioId ? radioInfo[i].radioId : "radio" + i %>" class="label"><%- radioInfo[i].txtLabel %></label>
</div>
<% } %>

Related Posts