This project has moved and is read-only. For the latest updates, please go here.

Jurassic and handlebars.js

Oct 16, 2012 at 12:46 PM
Edited Oct 16, 2012 at 4:07 PM

Not sure if this is an issue of Jurassic so I'm posting it in the discussions.

I want to precompile handlebars templates so I need Jurassic to compile the handlebars script on the server side. Here is what I wrote:

var engine = new ScriptEngine();
engine.Execute(@"var precompile = Handlebars.precompile;");

compiledTemplate = string.Format("<script type=\"text/javascript\">var {0} = Handlebars.template({1});</script>",
    name, engine.CallGlobalFunction("precompile", template).ToString());

It works well for a very simple handlebars (i.e. Mustache compatible) template. But I have this issue when it complicates:

If I use a handlebars construct like {{#if comments}}{{comments}}{{/if}} then I get an exception in CallGlobalFunction: System.InvalidOperationException: Unsupported object type. Of course, I tested it without Jurassic compilation and it works well with Handlebars alone.


Oct 16, 2012 at 3:21 PM
Edited Oct 16, 2012 at 4:05 PM

On the Handlebars forums, I'm told that this is probably a Jurassic issue.

Jan 30, 2013 at 7:39 PM

Any update on this?  Using Jurassic with Handlebars.js is pretty much useless without a proper way to handle basic constructs and helpers.