Answer the question
In order to leave comments, you need to log in
Problem with handlebars, how to connect?
I have a module in my project that requires backbone, which in turn requires underscore,jquery. I am using the gulp faucet and the gulp-requirejs module for it.
here is my task
/*********************************
task for js with require js
*********************************/
gulp.task('js',['cRqJs','mReq']);
//marge js files
gulp.task('cRqJs',function(){
rjs({
name: 'main',
baseUrl:'./js/',
out:'main.js',
paths:{
'jquery':'vendor/jquery/dist/jquery.min',
'backbone':'vendor/backbone/backbone',
'underscore':'vendor/underscore/underscore-min',
'handlebars':'vendor/handlebars/handlebars.amd.min'
}
})
.pipe(connect.reload())
.pipe(gulp.dest('app/js/'));
})
//task for minify js file
gulp.task('jsmin',function(){
rjs({
name: 'main',
baseUrl:'./js/',
out:'main.js',
paths:{
'jquery':'vendor/jquery/dist/jquery.min',
'backbone':'vendor/backbone/backbone',
'underscore':'vendor/underscore/underscore-min',
'handlebars':'vendor/handlebars/handlebars.min'
}
})
.pipe(jsmin())
.pipe(gulp.dest('app/js/'));
})
//replace require js
gulp.task('mReq',function(){
gulp.src('js/vendor/require/build/require.min.js')
.pipe(gulp.dest('app/js/vendor/'));
})
require(['views/app.js'],function(AppView){
//подключаем свой собственный модуль
new AppView;
});
define(['backbone','handlebars'],function(Backbone){
var App = Backbone.View.extend({
initialize:function(){
console.log('Hello!');
},
});
return App;
});
Answer the question
In order to leave comments, you need to log in
Handlebars, on the other hand, uses a modular structure if present and does not add itself to window.
Connect correctly:
define(['backbone','handlebars'],function(Backbone, ?){ // <- тут пропущено его подключение
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question