Common Lisp implementation of Google's Closure Templates.
Pull request Compare This branch is 95 commits behind archimag:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
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$;
};"