Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhoukekestar/jadewalker
URL mapping for jade.
https://github.com/zhoukekestar/jadewalker
Last synced: about 5 hours ago
JSON representation
URL mapping for jade.
- Host: GitHub
- URL: https://github.com/zhoukekestar/jadewalker
- Owner: zhoukekestar
- License: mit
- Created: 2016-11-30T08:34:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-08T08:27:42.000Z (over 7 years ago)
- Last Synced: 2024-11-14T04:57:27.811Z (6 days ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jadewalker
URL mapping for jade & pug. Because we can't create dynamic routers like this: [More Detail](http://stackoverflow.com/questions/25623041/how-to-configure-dynamic-routes-with-express-js)```js
entries.map(entry => {
router.get(entry.url, req => res.render(entry.view));
})
```# Install & Usage
* `npm install jadewalker` to install jadewalker.
* Set jadewalker in `jade` OR `pug` file.
```jade
//- jadewalker=/hello/:name
doctype html
html
title jadewalker
body
p Hello #{params.name || "jadewalker"}!
```
* API
* `router` Express router OR Koa router.
* `dir` View directory.
* `type`
* `express` Create routers for Express application.
* `koa` Create routers for Koa application.
* `koa2` Create routers for Koa@2 application.# Koa2
```js
const Koa = require('koa');
const Router = require('koa-router');
const views = require('koa-views');
const jadewalker = require('../index.js');const app = new Koa();
const router = new Router();app.use(views(`${__dirname}/views`));
jadewalker({
router,
dir: `${__dirname}/views`,
type: 'koa2'
});app.use(router.routes());
app.listen(3000);
```# Express
```js
const express = require('express')
const jadewalker = require('../index.js');const app = express();
app.set('views', `${__dirname}/views`);
app.set('view engine', 'jade');jadewalker({
router: app,
dir: `${__dirname}/views`,
type: 'express'
});app.listen(3000);
```# Debug
Set `NODE_DEBUG=jadewalker` to show debug log.