Permalink
Browse files

Closes #259, Fix error where no properties at all would throw when co…

…mpiling templates. Now if no default is given it will use the ID property, and when looping will only add the items template if it has content in it's name field

Conflicts:

	templates/Jakefile
  • Loading branch information...
1 parent ca35849 commit 515a929c41b84d20677e98301d8eaaf3bbf06fa4 @larzconwell larzconwell committed Nov 10, 2012
View
6 templates/Jakefile
@@ -253,10 +253,12 @@ namespace('gen', function () {
};
var _formatModelProperties = function (properties) {
+ var obj = {default: {name: '', type: ''}};
if (!properties) {
- return {};
+ return obj;
}
- var obj = {'default': {name: 'id', type: 'int'}};
+ obj['default'].name = 'id';
+ obj['default'].type = 'int';
var itemsArr = properties.split('%')
, name
View
2 templates/scaffold/model.ejs
@@ -2,7 +2,7 @@ var <%= names.constructor.singular %> = function () {
this.defineProperties({
<% for (var i in properties) { -%>
-<% if (properties[i].name !== 'id') { -%>
+<% if (properties[i].name && properties[i].name !== 'id') { -%>
<% if (i === 'default') { -%>
<%= properties[i].name %>: {type: '<%= properties[i].type %>', required: true},
<% } else { -%>
View
2 templates/scaffold/realtime/views/ejs/form.html.ejs.ejs
@@ -1,5 +1,5 @@
<% for(var i in properties) { -%>
-<% if(properties[i].name !== 'id') { -%>
+<% if(properties[i].name && properties[i].name !== 'id') { -%>
<div class="control-group">
<label for="<%= properties[i].name %>" class="control-label"><%= properties[i].name %></label>
<div class="controls">
View
4 templates/scaffold/realtime/views/ejs/index.html.ejs.ejs
@@ -8,7 +8,7 @@
<@ for (var i = 0, ii = <%= names.property.plural %>.length; i < ii; i++) { @>
<div class="row list-item" id="<%= names.property.singular %>-<@= <%= names.property.plural %>[i].id; @>">
<div class="span8">
- <h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name %>, <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
+ <h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name || "id" %>, <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
</div>
<div class="span4">
<h3><i class="icon-list-alt"></i><@= <%= names.property.plural %>[i].id; @></h3>
@@ -26,7 +26,7 @@ $(function () {
var template = [ ''
, '<div class="row list-item" id="<%= names.property.singular %>-' + <%= names.property.singular %>.id + '">'
, ' <div class="span8">'
- , ' <h3><a href="/<%= names.property.plural %>/' + <%= names.property.singular %>.id + '">' + <%= names.property.singular %>.<%= properties['default'].name %> + '</a></h3>'
+ , ' <h3><a href="/<%= names.property.plural %>/' + <%= names.property.singular %>.id + '">' + <%= names.property.singular %>.<%= properties['default'].name || "id" %> + '</a></h3>'
, ' </div>'
, ' <div class="span4">'
, ' <h3><i class="icon-list-alt"></i>' + <%= names.property.singular %>.id + '</h3>'
View
2 templates/scaffold/realtime/views/ejs/show.html.ejs.ejs
@@ -1,5 +1,5 @@
<div class="hero-unit">
- <h2 class="<%= properties['default'].name %>"><@= <%= names.property.singular %>.<%= properties['default'].name %> @></h2>
+ <h2 class="<%= properties['default'].name || "id" %>"><@= <%= names.property.singular %>.<%= properties['default'].name || "id" %> @></h2>
<@- linkTo('Edit this <%= names.property.singular %>', edit<%= names.constructor.singular %>Path(params.id), {class: 'btn pull-right'}); @>
</div>
View
2 templates/scaffold/realtime/views/jade/form.html.jade.ejs
@@ -1,5 +1,5 @@
<% for(var i in properties) { -%>
-<% if(properties[i].name !== 'id') { -%>
+<% if(properties[i].name && properties[i].name !== 'id') { -%>
.control-group
label(for="<%= properties[i].name %>", class="control-label") <%= properties[i].name %>
.controls
View
4 templates/scaffold/realtime/views/jade/index.html.jade.ejs
@@ -7,7 +7,7 @@ div#<%= names.property.plural %>-list
each <%= names.property.singular %> in <%= names.property.plural %>
.row.list-item(id="<%= names.property.singular %>-" + <%= names.property.singular %>.id)
.span8
- h3!= linkTo(<%= names.property.singular %>.<%= properties['default'].name %>, <%= names.property.singular %>Path(<%= names.property.singular %>.id))
+ h3!= linkTo(<%= names.property.singular %>.<%= properties['default'].name || "id" %>, <%= names.property.singular %>Path(<%= names.property.singular %>.id))
.span4
h3
i.icon-list-alt
@@ -21,7 +21,7 @@ script(type="text/javascript")
var template = [ ''
, '<div class="row list-item" id="<%= names.property.singular %>-' + <%= names.property.singular %>.id + '">'
, ' <div class="span8">'
- , ' <h3><a href="/<%= names.property.plural %>/' + <%= names.property.singular %>.id + '">' + <%= names.property.singular %>.<%= properties['default'].name %> + '</a></h3>'
+ , ' <h3><a href="/<%= names.property.plural %>/' + <%= names.property.singular %>.id + '">' + <%= names.property.singular %>.<%= properties['default'].name || "id" %> + '</a></h3>'
, ' </div>'
, ' <div class="span4">'
, ' <h3><i class="icon-list-alt"></i>' + <%= names.property.singular %>.id + '</h3>'
View
2 templates/scaffold/realtime/views/jade/show.html.jade.ejs
@@ -1,5 +1,5 @@
.hero-unit
- h2= <%= names.property.singular %>.<%= properties['default'].name %>
+ h2.<%= properties['default'].name || "id" %>= <%= names.property.singular %>.<%= properties['default'].name || "id" %>
!= linkTo('Edit this <%= names.property.singular %>', edit<%= names.constructor.singular %>Path(params.id), {class: 'btn pull-right'})
h2 <%= names.constructor.singular %> Properties
View
2 templates/scaffold/views/ejs/form.html.ejs.ejs
@@ -1,5 +1,5 @@
<% for(var i in properties) { -%>
-<% if(properties[i].name !== 'id') { -%>
+<% if(properties[i].name && properties[i].name !== 'id') { -%>
<div class="control-group">
<label for="<%= properties[i].name %>" class="control-label"><%= properties[i].name %></label>
<div class="controls">
View
2 templates/scaffold/views/ejs/index.html.ejs.ejs
@@ -8,7 +8,7 @@
<@ for (var i = 0, ii = <%= names.property.plural %>.length; i < ii; i++) { @>
<div class="row list-item" id="<%= names.property.singular %>-<@= <%= names.property.plural %>[i].id; @>">
<div class="span8">
- <h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name %>, <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
+ <h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name || "id" %>, <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
</div>
<div class="span4">
<h3><i class="icon-list-alt"></i><@= <%= names.property.plural %>[i].id; @></h3>
View
2 templates/scaffold/views/ejs/show.html.ejs.ejs
@@ -1,5 +1,5 @@
<div class="hero-unit">
- <h2 class="<%= properties['default'].name %>"><@= <%= names.property.singular %>.<%= properties['default'].name %> @></h2>
+ <h2 class="<%= properties['default'].name || "id" %>"><@= <%= names.property.singular %>.<%= properties['default'].name || "id" %> @></h2>
<@- linkTo('Edit this <%= names.property.singular %>', edit<%= names.constructor.singular %>Path(params.id), {class: 'btn pull-right'}); @>
</div>
View
2 templates/scaffold/views/jade/form.html.jade.ejs
@@ -1,5 +1,5 @@
<% for(var i in properties) { -%>
-<% if(properties[i].name !== 'id') { -%>
+<% if(properties[i].name && properties[i].name !== 'id') { -%>
.control-group
label(for="<%= properties[i].name %>", class="control-label") <%= properties[i].name %>
.controls
View
2 templates/scaffold/views/jade/index.html.jade.ejs
@@ -7,7 +7,7 @@ div#<%= names.property.plural %>-list
each <%= names.property.singular %> in <%= names.property.plural %>
.row.list-item(id="<%= names.property.singular %>-" + <%= names.property.singular %>.id)
.span8
- h3!= linkTo(<%= names.property.singular %>.<%= properties['default'].name %>, <%= names.property.singular %>Path(<%= names.property.singular %>.id))
+ h3!= linkTo(<%= names.property.singular %>.<%= properties['default'].name || "id" %>, <%= names.property.singular %>Path(<%= names.property.singular %>.id))
.span4
h3
i.icon-list-alt
View
2 templates/scaffold/views/jade/show.html.jade.ejs
@@ -1,5 +1,5 @@
.hero-unit
- h2= <%= names.property.singular %>.<%= properties['default'].name %>
+ h2.<%= properties['default'].name || "id" %>= <%= names.property.singular %>.<%= properties['default'].name || "id" %>
!= linkTo('Edit this <%= names.property.singular %>', edit<%= names.constructor.singular %>Path(params.id), {class: 'btn pull-right'})
h2 <%= names.constructor.singular %> Properties

0 comments on commit 515a929

Please sign in to comment.