English 中文(简体)
Question on using mustache partials with couchapp and evently
原标题:

I have been evaluating couchdb for a project and am using couchapp to develop the prototype. So far all I can only say it that it is an awesome tool. I have however run across a problem (which is surely caused by ignorance of the tool) that I cannot seem to get mustache partials to work and the reason for that I believe is that evently can t find the definitions of the partials I am using.

example out of a message queue evently template (evently/queues/_change/mustache.html)

<div class="queue">{{>queue_info}}</div>
...

and I have a queue_info.html with something like

<h2>{{name}}</h2>

where do I place the "queue_info.html" so that evently would find it and insert it properly? If I put it in the same directory as mustache.html it doesn t work.

Best regards, Vukasin

最佳回答

ok i have figured this out so I am writing to help anyone who might run into the same issue in the future:

if you have data:

{  "queue_info": { "name": "queuename", "owner": "user1" }, "messages": [...] }

and you want to render the "queue_info" part using a partial you will need to create the partial called "queue_info" (it is important that the partial is called the same as the field) and place it in a file "queue_info.html" located in the subdirectory "partials" of the evently directory you are working in).

so we have evently/queues/_change/mustache.html

<div class="queue">
{{>queue_info}}
{{#messages}}
   <div class="message">
       author: {{author}}
       message: {{text}}
   </div>
{{/messages}}
</div>

and evently/queues/_change/partials/queue_info.html

Queue: {{name}}
Owner: {{owner}}

when we push this couchapp to the server we get a result which cascades as expected.

Hope this helps someone :-)

问题回答

暂无回答




相关问题
couchdb for /really/ distributed replica

let s say i want to implement a distributed database (each node being the replica of the others); i hear that cdb is able to easily sync between two nodes and at least support some form of conflict ...

CouchDB View, Map, Index, and Sequence

I think read somewhere that when a View is requested the "map" is only run across documents that have been added since the last time it was requested? How is this determined? I thought I saw something ...

representing a many-to-many relationship in couchDB

Let s say I m writing a log analysis application. The main domain object would be a LogEntry. In addition. users of the application define a LogTopic which describes what log entries they are ...

couchDB , python and authentication

I have installed couchDB v 0.10.0, and am attempting to talk to it via python from Couch class downloaded from couchDB wiki. Problem is: Create database mydb : { error : unauthorized , reason : ...

Temp View Caching?

I m using CouchDB with a home-grown C# interface library. The most common method of accessing CouchDB with this library results in a temp view being created. I ve optimized the library so that it uses ...

热门标签