dsroute
Discus Route. Route system for SPA (Single Page Applications)
Last updated 9 months ago by discustecnologia .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dsroute 
SYNC missed versions from official npm registry.

dsRoute - Discus Route

logo Discus Tecnologia

Route system for SPA (Single Page Applications)


Use less data traffic and make your application faster

  • Resources:

    • Lazy loading templates using ajax
    • Optional cache for loaded templates
    • Define a default route and error code routes
  • Dependencies:

Example

index.html

!DOCTYPE html>
<html>
<head>
	<title>dsRoute Example</title>
	<meta charset="UTF-8">
</head>
<body>
	<div>
		<h1>Base application</h1>
	</div>
	<div id="content"></div>
</body>
	<script src="signals.min.js"></script>
	<script src="crossroads.min.js"></script>
	<script src="hasher.min.js"></script>
	<script src="jquery.min.js"></script>
	<script src="dsRoute.js"></script>
	<script src="app.js"></script>
</html>

app.js

fooController = function(id){
	console.log('load view foo');
};

barController = function(id, slug){
	console.log('load view bar with parameters', id, slug);

dsRoute.setRoutes({
	//index route
	'' : {templateUrl : 'home.html', controller : fooController},
	//Route no cached template
	'foo' : {templateUrl : 'foo.html', controller : fooController, nocache : true},
	//Route with parameter and optional parameter
	'bar/{id}/:slug:' : {templateUrl : 'bar.html', controller : barController},
	//Route called when get 404 code error. You can use others code errors.
	'404' : {templateUrl : '404.html', controller : fooController},
	//Called when no route matched
	'default' : {templateUrl : 'default.html', controller : fooController}
});

The template by default are showed on element #content. If you need to change the default element use:

dsRoute.setElRouteView('#maincontent');

Install

via npm

npm install dsroute --save

via bower

bower install dsroute --save

License

Copyright © 2017 Discus Tecnologia

Released under the MIT license.

Current Tags

  • 1.0.2                                ...           latest (9 months ago)

3 Versions

  • 1.0.2                                ...           9 months ago
  • 1.0.1                                ...           9 months ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (4)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |