Created
November 16, 2016 17:31
-
-
Save beck/5c0f19d1669554d07f329e35aab23fe0 to your computer and use it in GitHub Desktop.
Lodash and Amersand Router clash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global.location = {}; | |
| global.location.replace = function(){}; | |
| global.location.href = ''; | |
| global.location.pathname = ''; | |
| global.window = {}; | |
| global.window.location = global.location; | |
| var partialRight = require('lodash').partialRight; | |
| var partial = require('lodash').partial; | |
| var AmpRouter = require('ampersand-router'); | |
| var msg = function(greet, name) { | |
| console.log(greet, name, '!'); | |
| }; | |
| var Router = AmpRouter.extend({ | |
| routes: { | |
| ':msg/jo': 'jo', | |
| 'hi/:name': 'hi', | |
| }, | |
| jo: partialRight(msg, 'jo'), | |
| hi: partial(msg, 'hi'), | |
| }); | |
| var r = new Router(); | |
| r.history.start(); | |
| r.navigate('sup/jo'); | |
| r.navigate('hi/sam'); | |
| process.exit(); | |
| // console outuput: | |
| // sup null ! | |
| // hi sam ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment