lib/rid/generators/show/templates/show.js in rid-0.3.1 vs lib/rid/generators/show/templates/show.js in rid-0.4.0
- old
+ new
@@ -1,20 +1,22 @@
function(doc, req) {
- var head = '<html><head><link rel="stylesheet" href="../../stylesheets/application.css" type="text/css" media="screen" charset="utf-8"></head><body>';
- var body = '';
- var tail = '</body></html>';
+ // !code mustache.js
+ // !json templates/layout.mustache
+ // !json templates/<%= pluralized_model_name %>/show.mustache
+
if(doc) {
- body += '<p><a href="../../_list/<%= pluralized_model_name %>/<%= pluralized_model_name %>">List <%= pluralized_model_name.humanize %></a></p>';
-<% attributes.each do |attribute| -%>
- if(doc['<%= attribute %>']) {
- body += '<p><strong><%= attribute.humanize %></strong>: ' + doc['<%= attribute %>'] + '</p>';
- }
-<% end -%>
- return head + '<h1>Showing <%= model_name.humanize %></h1>' + body + tail;
+ provides("html", function() {
+ var view = {
+ title: "Showing <%= model_name.humanize %>",
+ body: {
+ title: doc.title,
+ body: doc.body,
+ id: doc._id
+ }
+ };
+
+ return Mustache.to_html(templates.layout, view, { body: templates.<%= pluralized_model_name %>.show });
+ });
} else {
-<% attributes.each do |attribute| -%>
- body += '<p><label><%= attribute.humanize %></label>: <input type="text" name="<%= model_name %>[<%= attribute %>]" id="<%= model_name %>_<%= attribute %>" /></p>';
-<% end -%>
- body += '<p><input type="submit" /> <a href="../../_list/<%= pluralized_model_name %>/<%= pluralized_model_name %>">Cancel</a></p>';
- return head + '<h1>New <%= model_name.humanize %></h1>' + body + tail;
+ return '404 not found';
}
}