Additional helper for handlebars, include marionette
or backbone
views into template and inject it to parent LayoutView.
npm install --save-dev injectify injectify-view
Configure gulp
:
let gulp = require('gulp'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
require('injectify-view/inject');
gulp.task('js', function () {
let bundleStream = browserify('./src/index.spec.js')
.transform(require("injectify"))
.bundle();
return bundleStream
.pipe(source('index.spec.js'))
.pipe(gulp.dest('dist'));
});
In file ./src/index.spec.js
require injectify view
helper:
import 'injectify-view';
Now you can use view
helper in your templates. For example define layout:
var Layout = Marionette.View.extend({
template: require("./tpl/Layout.hbs")
});
and template
In Layout
will be created test
region and view will be putted in.
view
helper works like original browserify require
. You can require modules relative to template file or
node_modules
directory.
- Marionette 3.0
- Change method of internal content render, can be BC for some projects
- Allow minor version updates of dependencies
- Handlebars 3
- Injectify 2