Socket
Socket
Sign inDemoInstall

marionette-routes-helper

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    marionette-routes-helper

Add helper methods for Backbone.Marionette routes


Version published
Maintainers
1
Install size
2.06 MB
Created

Changelog

Source

1.1.0

  • Integrate with Marionette 3.x.x
  • Upgrade dependencies

Readme

Source

Backbone.Marionette routes helper

Adds helper methods for Backbone.Marionette routes

Build Status

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 = require('marionette-routes-helper');

How to use:

First you should initialize routes helper and pass to it the application root path.

MarionetteRoutesHelper.initialize({ root: '/' });

Next you should bind routes helper to your router. For example:

var Controller = Marionette.Object.extend({
  method: function() { ... }
});

var Router = Marionette.AppRouter.extend({
  appRoutes: {
    "some/route": "method"
  },

  routes: {
    "other/route/:id": "otherMethod"
  },

  controller: new Controller()

  otherMethod: function() { ... }
});

MarionetteRoutesHelper.bind('myrouter', new Router());

Now routes methods are available for you. They are based on the following pattern routerName + RouterMethodName + "Path"

MarionetteRoutesHelper.myrouterMethodPath() // returns "some/route"
MarionetteRoutesHelper.myrouterOtherMethodPath(12) // 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.initialized()) {
  MarionetteRoutesHelper.initialize({ root: '' });
}
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:

Keywords

FAQs

Last updated on 07 Oct 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc