Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
backbone-named-routes
Advanced tools
Backbone router implementation with named routes (aliases) for easy client side links generation
Backbone router extension with named routes for easy client side links generation. Keep your url logic in one place and never type urls by hand again. Weighs less than 2KB.
Tired of hand coding those pesky href attributes on anchors and having to go through all templates when urls are changed? This named router extension allows you to generate urls from named routes or route aliases. Your url structure is already written and defined in your standard Backbone router - it is a good place to generate urls from.
Extend named router and define your routes as you usually do:
var Router = BackboneNamedRouter.extend({
routes: {
'': 'home',
'help': 'help',
'search/:query': 'search',
'search/:query/p:page': 'searchOnPage',
'file/*path': 'downloadFile',
'docs/:section(/:subsection)': 'docs'
},
...
Create router instance:
var router = new Router({
baseUrl: 'http://mysite.loc',
usesPushState: true,
root: ''
});
Get urls where and when you need them.
// outputs: 'http://mysite.loc'
router.url('home');
// outputs: 'http://mysite.loc/help'
router.url('help');
// outputs: 'http://mysite.loc/search/my-query'
router.url('search', {query: 'my-query'});
// outputs: 'http://mysite.loc/search/my-query/p2'
router.url('searchOnPage', {query: 'my-query', page: 2});
// outputs: 'http://mysite.loc/file/myFile.pdf?campaign=email'
router.url('downloadFile', {path: 'myFile.pdf'}, {campaign: 'email'});
// outputs: 'http://mysite.loc/docs/backbone/router'
router.url('docs', {section: 'backbone', subsection: 'router'});
Start Backbone history
Backbone.history.start(router.getHistoryStartParams());
Navigating to named routes is easy as:
// http://mysite.loc/help
router.navigateToRoute('help')
// http://mysite.loc/search/backbone
router.navigateToRoute('search', {query: backbone});
Navigating to urls:
// help route handler is dispatched
router.navigateToUrl('http://mysite.loc/help');
// you can pass jquery anchor objects
$('a.appLink').on('click', function(e) {
e.preventDefault();
router.navigateToUrl($(e.currentTarget));
});
Backbone named routes is packaged as UMD library so you can use it in CommonJS and AMD environment or with browser globals.
npm install backbone-named-routes --save
// with bundlers
var BackboneNamedRouter = require('backbone-named-routes');
// with browser globals
var BackboneNamedRouter = window.BackboneNamedRouter;
FAQs
Backbone router implementation with named routes (aliases) for easy client side links generation
We found that backbone-named-routes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.