2.2.11 • Published 7 years ago

injectify-view v2.2.11

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Injectify view helper Build Status

Additional helper for handlebars, include marionette or backbone views into template and inject it to parent LayoutView.

Install

npm install --save-dev injectify injectify-view

Usage

Configure gulp:

var gulp = require("gulp"),
    browserify = require("browserify"),
    source = require("vinyl-source-stream"),
     
require("injectify-view/inject");
    
gulp.task('js', function () {
    var bundleStream = browserify('./src/index.spec.js')
        .transform(require("injectify"))
        .bundle();

    return bundleStream
        .pipe(source('index.spec.js'))
        .pipe(gulp.dest('dist'));
});

If Marionette defined globally you need to do nothing. Elsewhere:

// configure helper
require("injectify-view/marionette").setInstance(require("backbone.marionette"));

In file ./src/index.spec.js require injectify view helper:

require("injectify-view");

Now you can use view helper in your templates. For example define layout:

var Layout = Marionette.Layout.extend({
    template: require("./tpl/Layout.hbs")
});

and template

Layout with internal view: {{view "../Internal" "test" model=user someOption=123}}

Attributes of view helper:

1. Path to module with Backbone.View or Marionette.View
2. Name of region, that will appear on parent Layout. Optional. 
   It will generate unique name for you
3. Hash will be pass to view constructor, you can specify options and models in it

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.

Changelog

v2.2

  • Change method of internal content render, can be BC for some projects

v2.1

  • Allow minor version updates of dependencies

v2.0

  • Handlebars 3
  • Injectify 2
2.2.11

7 years ago

2.2.10

7 years ago

2.2.9

7 years ago

3.0.0

7 years ago

2.2.8

8 years ago

2.2.7

8 years ago

2.2.6

8 years ago

2.2.5

9 years ago

2.2.4

9 years ago

2.2.3

9 years ago

2.2.2

9 years ago

2.2.1

9 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.0

9 years ago

1.0.4

9 years ago

0.0.3

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago