Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Common Lisp implementation of Google's Closure Templates.
Common Lisp JavaScript Emacs Lisp Other

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
src
t
COPYING
README.markdown
closure-template-html-mode.el
closure-template.asd

README.markdown

cl-closuret-template - Common Lisp implementation of Closure Template from Google

Sample Code

 CL-USER> (asdf:operate 'asdf:load-op '#:closure-template)

 CL-USER> (asdf:operate 'asdf:load-op '#:parenscript)

 CL-USER> (defparameter *template* "
 /*
  *  Greets a person using 'Hello' by default.
  */
{namespace Closure-template.Example}
{template hello-name}
   {if not $greetingWorld}
      Hello {$name}!
   {else}
      {$greetingWorld} {$name}!
    {/if}
{/template}")
*TEMPLATE*


CL-USER> (closure-template:compile-template :common-lisp-backend *template*)
CLOSURE-TEMPLATE.EXAMPLE:HELLO-NAME
CL-USER> (closure-template.example:hello-name '(:name "Andrey"))
"  Hello Andrey! "
CL-USER> (closure-template.example:hello-name '(:name "Andrey" :greeting-world "Hi"))
"  Hi Andrey! "


CL-USER> (closure-template:compile-template :javascript-backend *template*)
"if (typeof ClosureTemplate == 'undefined') {
     var ClosureTemplate = {  };
};
if (typeof ClosureTemplate.Example == 'undefined') {
    ClosureTemplate.Example = {  };
};
ClosureTemplate.Example.helloName = function ($$data$$) {
    var $data$ = $$data$$ || {  };
    var $templateOutput$ = '';
    $templateOutput$ += ' ';
    if (!$data$.greetingWorld) {
        $templateOutput$ += ' Hello ';
        $templateOutput$ += $data$.name;
        $templateOutput$ += '! ';
    } else {
        $templateOutput$ += ' ';
        $templateOutput$ += $data$.greetingWorld;
        $templateOutput$ += ' ';
        $templateOutput$ += $data$.name;
        $templateOutput$ += '! ';
    };
    $templateOutput$ += '';
    return $templateOutput$;
};"
Something went wrong with that request. Please try again.