Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed model property declaration issue with excess commas. #288

Merged
merged 1 commit into from

3 participants

@whitepaperclip

No description provided.

@larzconwell

Can you copy this over to the resource model as well, please?

@mde mde merged commit 255b178 into geddy:master
@mde
Owner

Merged, thanks!

@larzconwell

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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) { -%>
Something went wrong with that request. Please try again.