A
A
Andrey Dyrkov2015-05-06 14:56:15
JavaScript
Andrey Dyrkov, 2015-05-06 14:56:15

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/'));
  })

As a result, I get one file in which there are all the necessary libraries and my modules, and handlbars are also there. But for some reason there is no templating object in window. I can’t understand the plague(
Maybe I need to connect it somehow to my friend?
Here is the main.js file
require(['views/app.js'],function(AppView){
  //подключаем свой собственный модуль 
  new AppView;
});

He connects this module
define(['backbone','handlebars'],function(Backbone){
  var App = Backbone.View.extend({
    initialize:function(){
      console.log('Hello!');
    },
  });
  return App;
});

The module itself in the dependencies says that handlebars is needed and requirejs connects it, it is in the file, but not in window ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2015-05-06
@VIKINGVyksa

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 question

Ask a Question

731 491 924 answers to any question