<% var page = this %>
  <div class="control-group wrapper" data-nested="true">
  <% if (_.isObject(settings)) { %>
    <fieldset class="fieldset">
      <legend><%- legend %></legend>
      <%
        _.each(_.keys(settings), function(key) {
          if (_.isObject(settings[key])) {
            var recursiveFieldset = page.template({settings: settings[key], legend: key, cluster: cluster});
        %>
            <%= recursiveFieldset %>
        <%
          } else {
        %>
            <div class="wrapper" data-nested="false">
              <label class="control-label" for="<%- key %>"><%- key %></label>
              <div class="controls">
                <input type="text" class="input-large" name="<%- key %>" value="<%- settings[key] %>" <%= cluster.task('deploy', 'running') ? 'disabled ' : '' %>/>
              </div>
            </div>
        <%
          }
        })
      %>
    </fieldset>
  <% } else { %>
    <label class="control-label" for="<%- legend %>"><%- legend %></label>
      <div class="controls">
        <input type="text" class="input-large" name="<%- legend %>" value="<%- settings %>" <%= cluster.task('deploy', 'running') ? 'disabled ' : '' %>/>
      </div>
  <% } %>
  </div>

<% var page = this %>
  <% if (_.isObject(settings)) { %>
    <div class="control-group wrapper" data-nested="true">
      <fieldset class="fieldset">
        <legend><%- legend %></legend>
        <%
          _.each(_.keys(settings), function(key) {
            if (_.isObject(settings[key])) {
              var recursiveFieldset = page.template({settings: settings[key], legend: key, cluster: cluster});
          %>
              <%= recursiveFieldset %>
          <%
            } else {
          %>
              <div class="wrapper" data-nested="false">
                <label class="control-label" for="<%- key %>"><%- key %></label>
                <div class="controls">
                  <input type="text" class="input-large" name="<%- key %>" value="<%- settings[key] %>" <%= cluster.task('deploy', 'running') ? 'disabled ' : '' %>/>
                </div>
              </div>
          <%
            }
          })
        %>
      </fieldset>
  <% } else { %>
    <div class="control-group wrapper" data-nested="false">
      <label class="control-label" for="<%- legend %>"><%- legend %></label>
        <div class="controls">
          <input type="text" class="input-large" name="<%- legend %>" value="<%- settings %>" <%= cluster.task('deploy', 'running') ? 'disabled ' : '' %>/>
        </div>
  <% } %>
  </div>

Save simple settings (which is not nested)
Save simple settings (which is not nested)
