couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zachary Zolton <zachary.zol...@gmail.com>
Subject Re: Javascript templating for shows/lists
Date Thu, 03 Dec 2009 21:55:12 GMT
Mustache.js, by the CouchDB dev team's very own Jan Lehnardt:
http://github.com/janl/mustache.js

This one is an all-around JavaScript utility library:
http://documentcloud.github.com/underscore/#template

This could be something to watch:
http://github.com/lmorchard/jquery-tal-template

On Thu, Dec 3, 2009 at 3:25 PM, Rhett Sutphin <rhett@detailedbalance.net> wrote:
> Hi Roger,
>
> On Dec 3, 2009, at 3:13 PM, Roger Binns wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> 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:
>>  http://books.couchdb.org/relax/design-documents/shows#Using%20Templates
>>
>> Engine:
>>  http://ejohn.org/blog/javascript-micro-templating
>>
>> 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 (o.foo) { %>
>  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.
>
> Rhett
>
>>
>> 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
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iEYEARECAAYFAksYKeIACgkQmOOfHg372QTh2ACeK4yirwjIqvlEaXx+ki6tegLM
>> /PcAn0SVnuFHFhkl0TWwUDYoWIXH6oAy
>> =jc5m
>> -----END PGP SIGNATURE-----
>
>

Mime
View raw message