Thursday, January 22, 2009

Trimpath error "context._MODIFIERS is undefined"

I was doing a little JavaScript templating with Trimpath today and at one point I was getting a nice error in my console of:

context._MODIFIERS is undefined

Looking through the trimpath code it turned out this was because I was passing in a string rather than an object as my context for the generation of the template. So I was effectively doing:

TrimPath.processDOMTemplate("someNodeId", "some string");

rather than:

TrimPath.processDOMTemplate("someNodeId", {key: "value", otherKey: "value"});

In my case I was getting the error because I forgot to eval some JSON before passing it to trimpath.