Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add real CRUD to handlebars/mustache
- Loading branch information
Ben Ng
committed
Jul 2, 2013
1 parent
be7b55d
commit 1edb87f
Showing
10 changed files
with
211 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
<div class="hero-unit"> | ||
<h3>Params</h3> | ||
{{#params}} | ||
<p>{{action}} action on {{controller}} controller.</p> | ||
{{/params}} | ||
<form id="<%= names.property.singular %>-form" class="form-horizontal" action="/<%= names.filename.plural %>" method="POST"> | ||
<fieldset> | ||
<legend>Create a new <%= names.constructor.singular %></legend> | ||
{{#if params.errors }} | ||
<div class="control-group"> | ||
<ul> | ||
{{#each params.errors}} | ||
<li>{{this}}</li> | ||
{{/each}} | ||
</ul> | ||
</div> | ||
{{/if}} | ||
|
||
{{{partial "form" this}}} | ||
|
||
<div class="form-actions"> | ||
<input type="submit" class="btn btn-primary" value="Add" /> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,23 @@ | ||
<div class="hero-unit"> | ||
<h3>Params</h3> | ||
{{#params}} | ||
<p>{{action}} action on {{controller}} controller.</p> | ||
{{/params}} | ||
</div> | ||
<form id="<%= names.property.singular %>-form" class="form-horizontal" action="/<%= names.filename.plural %>/{{params.id}}?_method=PUT" method="POST"> | ||
<fieldset> | ||
<legend>Update this <%= names.constructor.singular %></legend> | ||
{{#if params.errors}} | ||
<div class="control-group"> | ||
<ul> | ||
{{#each params.errors }} | ||
<li>{{this}}</li> | ||
{{/each}} | ||
</ul> | ||
</div> | ||
{{/if}} | ||
|
||
{{{partial "form" this}}} | ||
|
||
<div class="form-actions"> | ||
<input type="submit" class="btn btn-primary" value="Save" /> | ||
<input type="submit" class="btn btn-danger" value="Delete" formaction="/<%= names.filename.plural %>/{{params.id}}?_method=DELETE" /> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<% for(var i in properties) { -%> | ||
<% 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"> | ||
<% if(properties[i].type === 'string') { -%> | ||
<% if(properties[i].name === 'password') { -%> | ||
<input type="password" class="span6" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } else { -%> | ||
<input type="text" class="span6" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } -%> | ||
<% } else if(properties[i].type === 'text') { -%> | ||
<textarea rows="10" class="span6" name="<%= properties[i].name %>"></textarea> | ||
<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%> | ||
<input type="number" class="span2" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } else if(properties[i].type === 'boolean') { -%> | ||
<select name="<%= properties[i].name %>", class="span1"> | ||
{% if <%= names.property.singular %>.<%= properties[i].name %> %} | ||
<option>false</option> | ||
<option selected>true</option> | ||
{% else %} | ||
<option selected>false</option> | ||
<option>true</option> | ||
{% endif %} | ||
</select> | ||
<% } else if(properties[i].type === 'datetime') { -%> | ||
<input type="datetime" class="span3" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } else if(properties[i].type === 'date') { -%> | ||
<input type="date" class="span2" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } else { -%> | ||
<%= properties[i].type %> | ||
<% } -%> | ||
</div> | ||
</div> | ||
<% } -%> | ||
<% } -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
<div class="hero-unit"> | ||
<h3>Params</h3> | ||
{{#params}} | ||
<p>{{action}} action on {{controller}} controller.</p> | ||
{{/params}} | ||
<h2>All <%= names.constructor.plural %></h2> | ||
<a href="/<%= names.property.plural %>/add" class="btn pull-right">Create a new <%= names.constructor.singular %></a> | ||
</div> | ||
|
||
<div id="<%= names.property.plural %>-list"> | ||
{{#each <%= names.property.plural %> }} | ||
<div class="row list-item" id="<%= names.property.singular %>-{{id}}"> | ||
<div class="span8"> | ||
<h3><a href="/<%= names.property.plural %>/{{id}}">{{id}}</a></h3> | ||
</div> | ||
<div class="span4"> | ||
<h3><i class="icon-list-alt"></i>{{id}}</h3> | ||
</div> | ||
</div> | ||
{{/each}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
<div class="hero-unit"> | ||
<h3>Params</h3> | ||
{{#params}} | ||
<p>{{action}} action on {{controller}} controller.</p> | ||
{{/params}} | ||
<h2 class="<%= properties['default'].name || "id" %>">{{ <%= names.property.singular %>.<%= properties['default'].name || "id" %> }}</h2> | ||
<a href="/<%= names.property.plural %>/{{params.id}}/edit" class="btn pull-right">Edit this <%= names.property.singular %></a> | ||
</div> | ||
|
||
<h2><%= names.constructor.singular %> Properties</h2> | ||
{{#each <%= names.property.singular %> }} | ||
<div class="row list-item"> | ||
<div class="span4"> | ||
<h3>{{@key}}</h3> | ||
</div> | ||
<div class="span8"> | ||
<h3><i class="icon-list-alt"></i><span class="{{ @key }}">{{ this }}</span></h3> | ||
</div> | ||
</div> | ||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
<div class="hero-unit"> | ||
<h3>Params</h3> | ||
{{#params}} | ||
<p>{{action}} action on {{controller}} controller.</p> | ||
{{/params}} | ||
<form id="<%= names.property.singular %>-form" class="form-horizontal" action="/<%= names.filename.plural %>" method="POST"> | ||
<fieldset> | ||
<legend>Create a new <%= names.constructor.singular %></legend> | ||
<div class="control-group"> | ||
<ul> | ||
{{#params.errors}} | ||
<li>{{.}}</li> | ||
{{/params.errors}} | ||
</ul> | ||
</div> | ||
|
||
{{{partial "form" this}}} | ||
|
||
<div class="form-actions"> | ||
<input type="submit" class="btn btn-primary" value="Add" /> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
<div class="hero-unit"> | ||
<h3>Params</h3> | ||
{{#params}} | ||
<p>{{action}} action on {{controller}} controller.</p> | ||
{{/params}} | ||
</div> | ||
<form id="<%= names.property.singular %>-form" class="form-horizontal" action="/<%= names.filename.plural %>/{{params.id}}?_method=PUT" method="POST"> | ||
<fieldset> | ||
<legend>Update this <%= names.constructor.singular %></legend> | ||
<div class="control-group"> | ||
<ul> | ||
{{#params.errors}} | ||
<li>{{.}}</li> | ||
{{/params.errors}} | ||
</ul> | ||
</div> | ||
|
||
{{{partial "form" this}}} | ||
|
||
<div class="form-actions"> | ||
<input type="submit" class="btn btn-primary" value="Save" /> | ||
<input type="submit" class="btn btn-danger" value="Delete" formaction="/<%= names.filename.plural %>/{{params.id}}?_method=DELETE" /> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<% for(var i in properties) { -%> | ||
<% 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"> | ||
<% if(properties[i].type === 'string') { -%> | ||
<% if(properties[i].name === 'password') { -%> | ||
<input type="password" class="span6" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } else { -%> | ||
<input type="text" class="span6" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } -%> | ||
<% } else if(properties[i].type === 'text') { -%> | ||
<textarea rows="10" class="span6" name="<%= properties[i].name %>"></textarea> | ||
<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%> | ||
<input type="number" class="span2" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } else if(properties[i].type === 'boolean') { -%> | ||
<select name="<%= properties[i].name %>", class="span1"> | ||
{% if <%= names.property.singular %>.<%= properties[i].name %> %} | ||
<option>false</option> | ||
<option selected>true</option> | ||
{% else %} | ||
<option selected>false</option> | ||
<option>true</option> | ||
{% endif %} | ||
</select> | ||
<% } else if(properties[i].type === 'datetime') { -%> | ||
<input type="datetime" class="span3" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } else if(properties[i].type === 'date') { -%> | ||
<input type="date" class="span2" name="<%= properties[i].name %>" value="{{<%= names.property.singular %>.<%= properties[i].name %>}}" /> | ||
<% } else { -%> | ||
<%= properties[i].type %> | ||
<% } -%> | ||
</div> | ||
</div> | ||
<% } -%> | ||
<% } -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
<div class="hero-unit"> | ||
<h3>Params</h3> | ||
{{#params}} | ||
<p>{{action}} action on {{controller}} controller.</p> | ||
{{/params}} | ||
<h2>All <%= names.constructor.plural %></h2> | ||
<a href="/<%= names.property.plural %>/add" class="btn pull-right">Create a new <%= names.constructor.singular %></a> | ||
</div> | ||
|
||
<div id="<%= names.property.plural %>-list"> | ||
{{#<%= names.property.plural %>}} | ||
<div class="row list-item" id="<%= names.property.singular %>-{{id}}"> | ||
<div class="span8"> | ||
<h3><a href="/<%= names.property.plural %>/{{id}}">{{id}}</a></h3> | ||
</div> | ||
<div class="span4"> | ||
<h3><i class="icon-list-alt"></i>{{id}}</h3> | ||
</div> | ||
</div> | ||
{{/<%= names.property.plural %>}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
<div class="hero-unit"> | ||
<h3>Params</h3> | ||
{{#params}} | ||
<p>{{action}} action on {{controller}} controller.</p> | ||
{{/params}} | ||
<h2 class="<%= properties['default'].name || "id" %>">{{ <%= names.property.singular %>.<%= properties['default'].name || "id" %> }}</h2> | ||
<a href="/<%= names.property.plural %>/{{params.id}}/edit" class="btn pull-right">Edit this <%= names.property.singular %></a> | ||
</div> | ||
|
||
<h2><%= names.constructor.singular %> Properties</h2> | ||
<% for(var i in properties) { -%> | ||
<div class="row list-item"> | ||
<div class="span4"> | ||
<h3><%= properties[i].name %></h3> | ||
</div> | ||
<div class="span8"> | ||
<h3><i class="icon-list-alt"></i> | ||
<span class="<%= properties[i].name %>"><% if(properties[i].name === 'id') { %>{{ params.id }}<% } else { %>{{ <%= names.property.singular %>.<%= properties[i].name %> }}<% } %></span></h3> | ||
</div> | ||
</div> | ||
<% } -%> |