Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #288 from whitepaperclip/master

Fixed model property declaration issue with excess commas.
  • Loading branch information...
commit 255b178d4b49a57ed91acd891522ebcb1069e833 2 parents 6ea15d0 + 063732f
@mde mde authored
Showing with 34 additions and 18 deletions.
  1. +17 −9 templates/resource/model.ejs
  2. +17 −9 templates/scaffold/model.ejs
View
26 templates/resource/model.ejs
@@ -1,15 +1,23 @@
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({
-<% for (var i in properties) { -%>
-<% 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 %>'},
-<% } -%>
-<% } -%>
-<% } -%>
+ <%- propertyOutput.join(",\n "); %>
});
<% for(var i in properties) { -%>
View
26 templates/scaffold/model.ejs
@@ -1,15 +1,23 @@
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({
-<% for (var i in properties) { -%>
-<% 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 %>'},
-<% } -%>
-<% } -%>
-<% } -%>
+ <%- propertyOutput.join(",\n "); %>
});
<% for(var i in properties) { -%>

0 comments on commit 255b178

Please sign in to comment.
Something went wrong with that request. Please try again.