incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nitin Borwankar <ni...@borwankar.com>
Subject switching between response content type in show? how to trigger html response inst of default xml
Date Fri, 24 Jul 2009 19:19:55 GMT
Hi guys,

so the list/show coding is going well - have the show running except for one
blocker - I am using curl to invoke the show (alost identical to example) in
couch app as follows - change dthe name from example to show_details in both
the shows code and lib/template - id in this request is "aacosta"  - the
template just returns a doc with the id in it

curl $CDB/ptest2/_design/vt2/_show/show_details/aacosta

<xml>
  <node value="aacosta"/>
</xml>

two questions

Why is the xml being sent back by default? What is the right param to pass
in to trigger the html?

show function is as follows


function(doc, req) {
  // !code lib/helpers/template.js
  // !json lib.templates

  respondWith(req, {
    html : function() {
      var html = template(lib.templates.show_details, doc);
      return {body:html}
    },
    xml : function() {
      return {
        body : <xml><node value={doc._id}/></xml>
      }
    }
  })
};


html template is as follows


<!DOCTYPE html>
<html>
  <head>
    <title>Details</title>
  </head>
  <body>
    <div id="docid">
      <h1><% doc._id %></h1>
    </div>
  </body>

</html>


Thanks much,




37% of all statistics are made up on the spot
-------------------------------------------------------------------------------------
Nitin Borwankar
nborwankar@gmail.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message