2.0.2 • Published 5 years ago
ferrugemjs-router v2.0.2
Router to FerrugemJS
A basic router implementation to FerrugemJS.
This is a basic implementation of routes for "Ferrugemjs", please feel free to do merge requests and improve this router or create your own. This router is implemented using page.js.
how to start:
clone skeleton-typescript (recomended way)
individual install
npm install ferrugemjs-router --save
in config.js.
"ferrugemjs-router":"node_modules/ferrugemjs-router/dist/router"
Usage
eg. init-app.html file
<template no-model>
<require from="ferrugemjs-router as rt" type="namespace"/>
<div>
<rt:router-view>
<route path="/list-modules" view="apps/module-list"/>
<route path="/module-a/:id" view="apps/module-a"/>
<route path="/module-b/:id" view="apps/module-b"/>
<route path="/module-b/:id/:name" view="apps/module-b"/>
</rt:router-view>
<h1>Router tests</h1>
<p>
<a href="/list-modules">modules</a>
</p>
<p>
<a href="/module-a/1">module-a</a>
</p>
<p>
<a href="/module-b/2">module-b</a>
</p>
<p>
<a href="/module-b/10/ops">change module-b name and id</a>
</p>
</div>
</template>
hashbang
<rt:router-view hashbang="true">
<route path="/list-modules" view="apps/module-list"/>
</rt:router-view>
redirect
<rt:router-redirect path="/list-modules"/>
redirect with timeout
<rt:router-redirect
path="/list-modules"
timeout="4000"
/>
base path
<rt:router-view base="/home/">
<route path="list-modules" view="apps/module-list"/>
</rt:router-view>
dinamic route list
constructor(){
this.routeList = [
{path:"/list-modules",view:"apps/module-list"}
,{path:"/module-a/:id",view:"apps/module-a"}
,{path:"/module-b/:id/:name",view:"apps/module-b"}
];
}
<rt:router-view routes="this.routeList"/>
redirect from a script tag
<script>
_rt.redirect({path:"/module-a/12",timeout:8000});
</script>
redirect from a representative function
<template>
<require from="ferrugemjs-router/index as router-redirect" type="script"/>
<div>
<router-redirect
path="/list-modules"
timeout="3000"
/>
</div>
</template>
redirect from a path to other
<rt:router-view hashbang="true">
<route path="/" redirect="/list-modules"/>
<route path="/list-modules" view="apps/module-list"/>
</rt:router-view>
redirect from "/" to "/index.html"
<rt:router-view hashbang="true">
<route path="/" redirect="/index.html"/>
</rt:router-view>
2.0.2
5 years ago
2.0.0
5 years ago
0.31.1
6 years ago
0.31.0
6 years ago
0.30.0
6 years ago
0.29.0
6 years ago
0.28.0
6 years ago
0.27.0
6 years ago
0.25.0
6 years ago
0.24.0
6 years ago
0.22.2
6 years ago
0.22.1
6 years ago
0.22.0
6 years ago
0.21.0
7 years ago
0.17.0
7 years ago
0.16.3
7 years ago
0.15.1
7 years ago
0.15.0
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago
0.0.11
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago