function(doc, req) { // !code path.js // !code mustache.js // !json templates/layout.mustache // !json templates/<%= pluralized_model_name %>/show.mustache // !json templates/<%= pluralized_model_name %>/form.mustache // !json templates/<%= pluralized_model_name %>/delete.mustache provides("html", function() { var view = { path: path(), body: { path: path() } }; var partial; if(doc) { <% attributes.each do |attribute| -%> view.body['<%= attribute %>'] = doc['<%= attribute %>']; <% end -%> view.body.id = doc._id; if (req.query.edit != undefined) { // edit view.title = "Editing <%= model_name.humanize %>"; partial = "form"; } else { view.body.rev = doc._rev; if (req.query['delete'] != undefined) { // delete view.title = "Deleting <%= model_name.humanize %>"; partial = "delete"; } else { // show view.title = "Showing <%= model_name.humanize %>"; partial = "show"; } } } else { // new view.title = "New <%= model_name.humanize %>"; partial = "form"; } return Mustache.to_html(templates.layout, view, { body: templates.<%= pluralized_model_name %>[partial] }); }); }