diff --git a/mustache.js b/mustache.js index b0ad601..55b36c1 100644 --- a/mustache.js +++ b/mustache.js @@ -164,8 +164,11 @@ var Mustache = function() { while(parts.length) { p = parts.shift(); if(ctx[p] === undefined) { - src = context.toSource(); - src = src.replace(/^\(|\)$/g, ""); + if(typeof(context.toSource) == "function") { + src = context.toSource().replace(/^\(|\)$/g, ""); + } else { + src = context.toString(); + } throw({message: "'" + name + "' not found in context: " + src}); } ctx = ctx[p];