couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rhett Sutphin <>
Subject Re: Javascript templating for shows/lists
Date Thu, 03 Dec 2009 21:25:09 GMT
Hi Roger,

On Dec 3, 2009, at 3:13 PM, Roger Binns wrote:

> Hash: SHA1
> Can anyone recommend Javascript templating engines that can be used within
> the CouchDB server side for implementing shows and lists?  The Sofa weblog
> app (also described in the book) uses a nice small one from John Resig.
> Book section:
> Engine:
> I am looking for something a little more complex such as handling
> conditionals and automatically HTML escaping all values unless told
> otherwise for specific ones (ie make XSS harder to happen accidentally).

You can do conditionals in Resig's microtemplates -- they work sort of like ERB, if you've
used that:

<% if ( { %>
  Foo is true-ish
<% } else { %>
  Foo is not true-ish
<% } %>

Automatic HTML escaping might be possible, but you would have to modify the template engine.


> I can find several engines that will only run in the browser, or depend on a
> DOM being present, or load the templates from a URL, or require a complete
> HTML document to be present in the template (lists build row by row).  These
> are all deal breakers. Some are many kilobytes of code and require other
> libraries such as jQuery.  Will this much code be a problem for show/list usage?
> My plan is for the output to be somewhat plain but functional - ie usable on
> a mobile phone.  Then client side Javascript runs and adds functionality,
> increases information detail, improves formatting etc.  An example of this
> in sofa is that the CouchDB side formatting provides dates in output which
> client side Javascript then reformats and the client side also knows what
> the local timezone is.  Similarly client side javascript can add in icons,
> previews of next items, tooltips etc.  This all points to a simpler CouchDB
> server side templating engine.
> I'll summarise responses in the wiki.
> Roger
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -
> iEYEARECAAYFAksYKeIACgkQmOOfHg372QTh2ACeK4yirwjIqvlEaXx+ki6tegLM
> /PcAn0SVnuFHFhkl0TWwUDYoWIXH6oAy
> =jc5m

View raw message