为什么Handlebars.template(templateSpec)不能像(I)那样工作?

我试图预编译一个节点的应用程序中的句柄模板。 后来,我想存储/检索预编译模板到/从数据库并使用它。

var handlebars = require('handlebars'); var templateSpec = handlebars.precompile('{{foo}}'); var template = handlebars.template(templateSpec); 

我将此代码基于Handlebars参考 。

上面的代码会引发错误:

 /home/ubuntu/workspace/handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:50 throw new _exception2['default']('Unknown template object: ' + typeof templateSpec); ^ Error: Unknown template object: string at Object.template (/home/ubuntu/workspace/handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:50:11) at HandlebarsEnvironment.hb.template (/home/ubuntu/workspace/handlebars/node_modules/handlebars/dist/cjs/handlebars.runtime.js:51:20) at Object.<anonymous> (/home/ubuntu/workspace/handlebars/test.js:5:27) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:441:10) at startup (node.js:139:18) at node.js:990:3 

不知道我在做什么错。