English 中文(简体)
iteration on couchapp
原标题:

i had write this on mustache.html on couchapp

**{{%IMPLICIT-ITERATOR iterator=i}} {{#example}}

hallo {{i}}

{{/example}}**

with this array

{ "example": ["alpha","beta","gamma","delta"] }

but the result from couchapp is like this

hallo alpha,beta,gamma,delta

hallo alpha,beta,gamma,delta

hallo alpha,beta,gamma,delta

hallo alpha,beta,gamma,delta

how can i get just hallo beta and hallo delta?

Thanks

问题回答

This is one area where if you are not used to the "logic-less" templating, it can feel like you have some handcuffs. In short, if you just want to render a subset of an array in mustache, then you need to provide an array with just those elements you want to display.

AFAIK, there is no way to put conditional logic of the form "if element is a print it, otherwise don t print it". Of course, mustache provides some conditional execution based on if data is present or not (e.g. the {{^ foo}} statement). More fine tuned/complicated display logic is not possible.





相关问题
Getting UUIDs in a CouchApp with active vhost

I am looking for the right way for loading new UUIDs or accessing the _session object in a couchapp behind a vhost. I have written a couchapp and everything workes well with the normal but ugly urls. ...

CouchApp vs Node.js

On the frontend Im using Sproutcore. The question is how the backend is going to look like. Solutions: CouchApp Node.js between Sproutcore and CouchDB Could CouchApp really replace Node.js on the ...

How to TDD for CouchDB with CouchApp?

Recently I ve discovered CouchDB. I want to use CouchApp to build a flash games site. It looks like a perfect fit cause this kind of a site is totally document based with a bit of binary attachments. ...

Timeout in a Couchapp list when using mustache

I have a simple list view in which I (try to) use mutache to render the output of a list containing 5 results. function(head, req) { var row, mustache = require("vendor/couchapp/lib/mustache....

deploy application on couchdb

I would like to deploy my application on couchdb. Have few queries regarding the same. 1) Is couchapp the only way to install applications on couchdb? 2) Can we deploy only javascript/HTML in ...

how to get jquery.couch.app.js to work with IE8

I have tested this on Windows XP SP3 in IE7 and IE8 ( in all compatibility modes ) and Windows 7 Ultimate in IE8 (in all compatiblity modes) and it fails the same way on both. I am running the latest ...

热门标签