Skip to content

How to add extension along with filename in Declare? #10

@imran5387

Description

@imran5387

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions