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 %>/deleted.mustache var doc = { type: '<%= model_name %>', <% attributes.each do |attribute| -%> '<%= attribute %>': req.form['<%= attribute %>'], <% end -%> _id: req.form.id, _rev: req.form.rev }; if (req.form['delete'] == 'true') { doc._deleted = true; }; var view = { path: path(), body: { path: path(), <% attributes.each do |attribute| -%> '<%= attribute %>': doc['<%= attribute %>'], <% end -%> id: doc._id } }; var partial; if (doc._deleted) { view.title = "Deleted <%= model_name.humanize %>"; view.notice = "<%= model_name.humanize %> has been deleted."; partial = 'deleted'; } else { view.title = "Showing <%= model_name.humanize %>"; if (doc._rev) { view.notice = "<%= model_name.humanize %> has been updated."; } else { view.notice = "<%= model_name.humanize %> has been created."; }; partial = 'show'; } return [doc, Mustache.to_html(templates.layout, view, { body: templates.<%= pluralized_model_name %>[partial] })]; }