incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clemens Cap <...@unagon.com>
Subject Re: Newbie problem with template path
Date Mon, 01 Mar 2010 01:05:01 GMT
On 28.02.2010 03:28, Patrick Barnes wrote:
> To confirm...
> You *are* using couchapp to generate your design doc, keeping the view and
> show funcs in files, and the included files in the same couchapp area?

No, I am not.

I got a reply from Chris which pointed out that issue - and as a
consequence of this my issue got solved today at (local time) noon. :-)

Since his reply didn't make it to the list I provide the essentials here
for the benefit of others - since this was the missing link for me.

Thanx again !


==PASTE==
Ahh. the key is that you need to use `couchapp push` to upload your
design doc to the couch.

when it's pushed, the couch should have:

shows : {
  my : {
   "
function(doc) {
var templates = {
    edit : "TEXT"
 }
return templates.edit;
}
"
...

CouchDB itself has no idea about //!json, it's all in the toolchain.
(We're working on changing this but the syntax will be proper javascript
instead of a macro. This will be in 0.11 and will make it easier for you.)

Couchapp push is required. Without it of course you could just put the
template into your function by hand, but that's no fun.

Chris

==PASTE==


> 
> -Patrick
> 
> On 28/02/2010 6:57 AM, "Clemens Cap" <cap@unagon.com> wrote:
> 
> I am having a problem to understand the path where the engine looks for
> the files included with the !json and !code macros.
> 
> More exactly: I am having a
> 
> {
>   "_id": "_design/example",
>   "_rev": "11-4ca79b908a6278eeb8d4d5e2e6488fb5",
>   "views": {
>       "foo": {
>           "map": "function(doc){ emit(doc._id, doc._rev+'QQQ')}"
>       }
>   },
>   "shows": {
>       "my": "function(req, doc) {
>                // !json templates.edit
>                return template(templates.edit,{})  ; }"
>   }
> }
> 
> and
> 
> http://localhost:5984/mydatabase/_design/example/_view/foo
> 
> as expected. However
> 
> http://localhost:5984/mydatabase/_design/example/_show/my
> 
> produces a
> 
> {"error":"normal","reason":"{gen_server,call,\n
> [couch_query_servers,\n
> {ret_proc,{proc,<0.21518.0>,<<\"javascript\">>,\n
>      {couch_os_process,prompt},\n
> {couch_os_process,set_timeout},\n
> {couch_os_process,stop}}}]}"}
> 
> I am having a non-empty
> 
> {
>   "_id": "_design/template/_show/my",
>   "_rev": "2-7051cbe5c8faecd085a3fa619e6e6337"
> }
> 
> but this does not seem to help here. Moreover, where do I place the
> template content into this object ?
> 
> 
> I never got that part working so probably it is just a very stupid
> newbie error...
> 
> Best
> Clemens
> 


Mime
View raw message