You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My Gulp FIle is as shown below
var handlebars=require('gulp-handlebars');
var handlebarSrc = config.appBasePath + '/js/templates/*/.hbss',
handlebarDest = config.appBasePath + '/js/libs/iea/core/js/',
handlebarDestFile = config.parentAppName + '.templates.js';
gulp.task('handlebars', function() {
return gulp.src(handlebarSrc)
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'templates',
noRedeclare: true, // Avoid duplicate declarations
processName: function(filePath) {
var a= filePath.split("\presentation").pop();
//var a = String(filePath.replace('C:\xampp\htdocs\IEA-Test\presentation', ''));
/////entension was js somehow changing it to hbss below
a = a.replace('.js', ".hbss");
return (a);
}
}))
.pipe(concat(handlebarDestFile))
.pipe(wrap('define(["handlebars","helpers"], function(Handlebars) {<%= contents %>return this["templates"];});'))
.pipe(gulp.dest(handlebarDest));
});
Directory structure ::
js- templates- carousel- defaultView.hbss
js-templates- form- defaultView.hbss
js-templates-searchInput-defaultView.hbss
......................................-defaultView.hbss
... and so on
output template.js file
WHAT I GET
define(["handlebars","helpers"], function(Handlebars) {
this["templates"] = this["templates"] || {};
this["templates"]["lib/js/templates/adaptive-image/defaultView"] = this["templates"]["lib/js/templates/adaptive-image/defaultView"] || {};
/////change needed here
this["templates"]["lib/js/templates/adaptive-image/defaultView"]["hbss"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1;
+1,i want move grunt-contrib-handlebars to gulp,but gulp-handlebars can't support it.
Well,you can custom it's code:
// Default name processing function should give the filename without extensionvardefaultProcessName=function(name){vardirArr=path.dirname(name).split(path.sep);returndirArr[dirArr.length-1]+'/'+path.basename(name,path.extname(name));};
My Gulp FIle is as shown below
var handlebars=require('gulp-handlebars');
var handlebarSrc = config.appBasePath + '/js/templates/*/.hbss',
handlebarDest = config.appBasePath + '/js/libs/iea/core/js/',
handlebarDestFile = config.parentAppName + '.templates.js';
gulp.task('handlebars', function() {
return gulp.src(handlebarSrc)
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'templates',
noRedeclare: true, // Avoid duplicate declarations
processName: function(filePath) {
var a= filePath.split("\presentation").pop();
//var a = String(filePath.replace('C:\xampp\htdocs\IEA-Test\presentation', ''));
/////entension was js somehow changing it to hbss below
a = a.replace('.js', ".hbss");
return (a);
}
}))
.pipe(concat(handlebarDestFile))
.pipe(wrap('define(["handlebars","helpers"], function(Handlebars) {<%= contents %>return this["templates"];});'))
.pipe(gulp.dest(handlebarDest));
});
Directory structure ::
js- templates- carousel- defaultView.hbss
js-templates- form- defaultView.hbss
js-templates-searchInput-defaultView.hbss
......................................-defaultView.hbss
... and so on
output template.js file
WHAT I GET
define(["handlebars","helpers"], function(Handlebars) {
this["templates"] = this["templates"] || {};
this["templates"]["lib/js/templates/adaptive-image/defaultView"] = this["templates"]["lib/js/templates/adaptive-image/defaultView"] || {};
/////change needed here
this["templates"]["lib/js/templates/adaptive-image/defaultView"]["hbss"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1;
What I WANT::::
define(["handlebars","helpers"], function(Handlebars) {
this["templates"] = this["templates"] || {};
this["templates"]["lib/js/templates/adaptive-image/defaultView.hbss"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1;
Let me Know what is to be done in gulpfile handlebars to include extension in processName
The text was updated successfully, but these errors were encountered: