contently / videojs-annotation-comments

A plugin for video.js to add support for timeline moment/range comments and annotations
https://contently.github.io/videojs-annotation-comments/
Other
171 stars 50 forks source link

VIDEOJS: ERROR: TypeError: templates[templateName] is not a function #81

Closed JohnnyIkarus closed 2 years ago

JohnnyIkarus commented 2 years ago

I tried running the project on my windows machine. i followed the readme and installed the project using the yarn commands. when i access the test page i get the following error inside my browser:

grafik

JohnnyIkarus commented 2 years ago

I was able to fix this problem by editing the gulpfile.js from:

...
gulp.task('templates', () => {
  gulp
    .src('./src/templates/**/*.hbs')
    .pipe(
      handlebars({
        handlebars: require('handlebars')
      })
    )
    .pipe(wrap('Handlebars.template(<%= contents %>)'))
    .pipe(
      declare({
        root: 'exports',
        noRedeclare: true, // Avoid duplicate declarations
        namespace: 'templates',
        processName: function (filePath) {
          // Allow nesting based on path using gulp-declare's processNameByPath()
          // You can remove this option completely if you aren't using nested folders
          // Drop the templates/ folder from the namespace path by removing it from the filePath
          return declare.processNameByPath(filePath.replace('src/templates/', '');
        }
      })
    )
    .pipe(concat('templates.js'))
    .pipe(wrap('var Handlebars = require("handlebars/runtime");\n <%= contents %>'))
    .pipe(gulp.dest('./src/js/compiled/'));
});
...

to

...
gulp.task('templates', () => {
  gulp
    .src('./src/templates/**/*.hbs')
    .pipe(
      handlebars({
        handlebars: require('handlebars')
      })
    )
    .pipe(wrap('Handlebars.template(<%= contents %>)'))
    .pipe(
      declare({
        root: 'exports',
        noRedeclare: true, // Avoid duplicate declarations
        namespace: 'templates',
        processName: function (filePath) {
          // Allow nesting based on path using gulp-declare's processNameByPath()
          // You can remove this option completely if you aren't using nested folders
          // Drop the templates/ folder from the namespace path by removing it from the filePath
          return declare.processNameByPath(filePath.replace('src/templates/', '').replace('src\\templates\\', ''));
        }
      })
    )
    .pipe(concat('templates.js'))
    .pipe(wrap('var Handlebars = require("handlebars/runtime");\n <%= contents %>'))
    .pipe(gulp.dest('./src/js/compiled/'));
});
...