Skip to content

Commit

Permalink
Merge pull request #288 from whitepaperclip/master
Browse files Browse the repository at this point in the history
Fixed model property declaration issue with excess commas.
  • Loading branch information
mde committed Dec 21, 2012
2 parents 6ea15d0 + 063732f commit 255b178
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
26 changes: 17 additions & 9 deletions templates/resource/model.ejs
@@ -1,15 +1,23 @@
var <%= names.constructor.singular %> = function () { var <%= names.constructor.singular %> = function () {
<%
var propertyOutput = [],
currentProperty;
for (var i in properties) {
if (properties[i].name && properties[i].name !== "id") {
currentProperty = properties[i].name + ": {type: '" + properties[i].type + "'";
if (i === "default") {
currentProperty += ", required: true";
}
currentProperty += "}";
propertyOutput.push(currentProperty);
}
}
%>
this.defineProperties({ this.defineProperties({
<% for (var i in properties) { -%> <%- propertyOutput.join(",\n "); %>
<% if (properties[i].name && properties[i].name !== 'id') { -%>
<% if (i === 'default') { -%>
<%= properties[i].name %>: {type: '<%= properties[i].type %>', required: true},
<% } else { -%>
<%= properties[i].name %>: {type: '<%= properties[i].type %>'},
<% } -%>
<% } -%>
<% } -%>
}); });


<% for(var i in properties) { -%> <% for(var i in properties) { -%>
Expand Down
26 changes: 17 additions & 9 deletions templates/scaffold/model.ejs
@@ -1,15 +1,23 @@
var <%= names.constructor.singular %> = function () { var <%= names.constructor.singular %> = function () {
<%
var propertyOutput = [],
currentProperty;
for (var i in properties) {
if (properties[i].name && properties[i].name !== "id") {
currentProperty = properties[i].name + ": {type: '" + properties[i].type + "'";
if (i === "default") {
currentProperty += ", required: true";
}
currentProperty += "}";
propertyOutput.push(currentProperty);
}
}
%>
this.defineProperties({ this.defineProperties({
<% for (var i in properties) { -%> <%- propertyOutput.join(",\n "); %>
<% if (properties[i].name && properties[i].name !== 'id') { -%>
<% if (i === 'default') { -%>
<%= properties[i].name %>: {type: '<%= properties[i].type %>', required: true},
<% } else { -%>
<%= properties[i].name %>: {type: '<%= properties[i].type %>'},
<% } -%>
<% } -%>
<% } -%>
}); });


<% for(var i in properties) { -%> <% for(var i in properties) { -%>
Expand Down

0 comments on commit 255b178

Please sign in to comment.