gruntjs/grunt-contrib-handlebars

Does not return Template when Pre-Processing as a partial using AMD

Opened this issue · 0 comments

Template:

This is just a basic template example

Job Options:

options: {
  partialRegex: /^/,
  processPartialName: function (filePath) {
    return filePath.replace(/^.*?templates\/(partials\/)?(.*?)\.(hbs|html)$/i, '$2');
  },
  amd: function amd(hbsFileName, ast) {
    var dependcies = ['Handlebars', 'plusMore'];
    return dependcies.join('\', \'');
  },
  processContent: function processContent(content) {
    return content.replace(/^[\x20\t]+/mg, '')
      .replace(/[\x20\t]+$/mg, '')
      .replace(/^[\r\n]+/, '')
      .replace(/[\r\n]*$/, '\n');
  }
}

Expected:

define(['Handlebars', 'plusMore'], function(Handlebars) {
var template;
Handlebars.registerPartial("basic", template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "This is just a basic template example\n";
},"useData":true}));

return template;

});

Actual

define(['Handlebars', 'plusMore'], function(Handlebars) {

Handlebars.registerPartial("basic", Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "This is just a basic template example\n";
},"useData":true}));

return ;

});

Notice the return statment returns undefined, I would expect that it would return the partial/template no mater what.