Vladimir Sedach

Have Emacs - Will Hack

November 18, 2009

Andrey Moskvitin's cl-closure-template

Topic: Lisp

Earlier this month Google released Closure Templates, a new templating library intended for generating HTML.

The one thing that makes Closure Templates somewhat interesting is that the library works in both Java and JavaScript, so you get client and server-side templates in one place. I did something similar with uri-template by having the URI template expand into code that executed in both Common Lisp and JavaScript via Parenscript.

About a week after Closure Templates was released, Andrey Moskvitin wrote an implementation in Common Lisp (it took Andrey only five days and 1/15 the number of lines of code as the original). The resulting system, cl-closure-template, similarly generates JavaScript via Parenscript.

Andrey wrote a blog post explaining the motivation for cl-closure-templates for Common Lisp programmers. Those pampered by web development in Common Lisp using s-expression HTML generation tools (such as CL-WHO) simply do not encounter the problem of trying to fit HTML templating onto the paradigm of incremental page updating via AJAX. So if you want to build an AJAX web application and use HTML templating, give cl-closure-template a try.