title: Injecting precompiled handlebars template in Handlebars.template method
body: <p>Hi I am currently using Express Handlebars setup [<a href="https://github.com/ericf/express-handlebars][1]" rel="nofollow">https://github.com/ericf/express-handlebars][1]</a> to render compiled and pre-compiled templates. In case of pre-compilation I have configured express middleware to get handlebars templates as precompiled and manually configured registration of handlebars pre-compiled templates like this:</p>
  
  <pre><code>hbs.getTemplates('views/partials/page/', {
                      cache      : app.enabled('view cache'),
                      precompiled: true
                  }).then(function (templates) {
  
             var templatesArr = hbs.handlebars.templates = hbs.handlebars.templates || {}
  
           // extract all templates names and values
          templates = Object.keys(hbs.handlebars.templates).map(function (name) {
  
                    //get precompiled template data
                    var templateSpec = templates[name]
  
                   //Inject precompiled data into Handlebars.template method
                   var precompileTemplateRef = hbs.handlebars.template(templateSpec)
  
                  //templateSpec is treated as String rather than Object 
                  //and this is where the things break because 
                  //handlebars.template expects Object
  
                  //Register precompileTemplateRef with Handlebars so that 
                  //precompiled template can be extracted for later use by using 
                  //template name
  
                  templatesArr[name] = precompileTemplateRef
  
   });
  </code></pre>
  
  <p>When I run the express server, hbs.handlebars.template doesn't get executed because templateSpec mentioned above is received as a string rather than object.</p>
  
  <p>Even using JSON.parse(templateSpec) doesn't work because precompiled output is not JSON BUT an Object literal.</p>
  
  <p>Precompiled output looks something like this:</p>
  
  <pre><code>{"1":function(container,depth0,helpers,partials,data) {var helper;ret.......
  </code></pre>
  
  <p>I want to know if its possible to inject just the pre-compiled output at run time into Handlebars.template(templateSpec) OR Do I have to create precompiled template in file system which has registration with Handlebars.templates.</p>
  
  <p>In case of compiled templates there are no issues.</p>
  
  <p>Many thanks in advance  </p>