Backbone.Marionette routes helper
Adds helper methods for Backbone.Marionette routes
Backbone.Marionette routes helper is the simple plugin which provides you methods with routes names for your application.
How to install:
npm install marionette-routes-helper
Browser:
<script>...</script><script src="backbone.radio.js" type="text/javascript"></script><script src="backbone.marionette.js" type="text/javascript"></script><script src="marionette-routes-helper.js" type="text/javascript"></script>
Common JS:
var MarionetteRoutesHelper = ;
How to use:
First you should initialize routes helper and pass to it the application root path.
MarionetteRoutesHelper;
Next you should bind routes helper to your router. For example:
var Controller = MarionetteObject; var Router = MarionetteAppRouter; MarionetteRoutesHelper;
Now routes methods are available for you. They are based on the following pattern routerName + RouterMethodName + "Path"
MarionetteRoutesHelper // returns "some/route"MarionetteRoutesHelper // returns "other/route/12"
Options
root: '/' // application root path
Methods
initialize
Signature: .initialize(options)
initialize
sets base options
initialized
Signature: .initialized()
initialized
returns boolean which define routes helper state. It is sometimes useful to check whether your routes helper is already initialized.
if !MarionetteRoutesHelper MarionetteRoutesHelper;
bind
Signature: .bind(routerName, routerInstance)
bind
binds routes helper with router instance
rootPath
Signature: .rootPath()
rootPath
returns the root path value which passed to it in initialize method
Thanks to:
- The Marionette team for backbone.marionette.js
- Anton Gudkov for the idea and first draft