https://github.com/missinglink/dubstep
A simple two step view pattern for expressjs
https://github.com/missinglink/dubstep
Last synced: over 1 year ago
JSON representation
A simple two step view pattern for expressjs
- Host: GitHub
- URL: https://github.com/missinglink/dubstep
- Owner: missinglink
- Created: 2013-01-20T01:57:55.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-01-20T02:22:55.000Z (over 13 years ago)
- Last Synced: 2025-01-22T08:13:43.444Z (over 1 year ago)
- Language: CoffeeScript
- Size: 105 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DubStep
A kind of response middleware for expressjs.
Lets you seperate and re-use view specific logic, keeping it out of your controllers.
Recipes coming soon.
## Example Steps
### A basic step used to set HTML title
```javascript
var title = function( title, function(req, res, step){
res.title = 'Company -- ' + title;
step();
});
```
### A view renderer
```javascript
var html = function(req, res, step){
res.send( ''+res.title+'
'+res.title+'
' );
};
```
## Define the steps in your express controller
```javascript
app.get('/home', function(req, res){
res.dub.step( title( 'Home Page' ) )
.step( html )
.step();
});
```
## Tests
```bash
npm test
```
```bash
dubstep
✓ should be a function that is compatible with connect middleware
middleware
✓ should define a function dub.step()
✓ should call next() once
steps
✓ should behave like a queue (first in first out)
✓ should stop when a step neglects to call the next step()
✓ should have access to req and res from connect
6 tests complete (3 ms)
```
## License
Released under the MIT(Poetic) Software license
This work 'as-is' we provide.
No warranty express or implied.
Therefore, no claim on us will abide.
Liability for damages denied.
Permission is granted hereby,
to copy, share, and modify.
Use as is fit,
free or for profit.
These rights, on this notice, rely.