https://github.com/becklyn/javascript-router
The JS implementation of Symfony's Router.
https://github.com/becklyn/javascript-router
Last synced: 4 months ago
JSON representation
The JS implementation of Symfony's Router.
- Host: GitHub
- URL: https://github.com/becklyn/javascript-router
- Owner: Becklyn
- License: bsd-3-clause
- Created: 2019-07-30T15:38:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-10T15:58:06.000Z (about 6 years ago)
- Last Synced: 2025-08-11T04:02:25.769Z (5 months ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
Symfony JavaScript Router
=========================
This is a modern implementation of the JS router for generation Symfony routes.
Best to be used with the [JavaScript routing bundle](https://github.com/Becklyn/javascript-routing-bundle).
Initialization
--------------
For example like this (using `mojave`):
```js
import {initFromGlobalData} from "mojave/init";
import {Router} from "@becklyn/router";
let router = initFromGlobalData("RouterInit", new Router());
```
A manual way to wire it up to global data is like this:
```js
function loadGlobalData (key, handler)
{
if (undefined === window[key])
{
return;
}
// replace global callback
window[key].init = (data) => handler.init(data);
// handle current data
handler.init(window[key].data);
}
let router = new Router();
loadGlobalData("RouterInit", router);
```