Capture remainder of URL with DoneJS

42 views Asked by At

Basically, what I'm aiming to do is capture the rest of a url in a route and store it into the ViewModel.

In AngularJS, you can do this:

$routeProvider.when('/foo/:page*', { ... });

...and when you access /foo/bar/baz, for example, $routeParams.page is 'bar/baz'.

So I attempted something similar in DoneJS, with the following line in the app.js:

route('/foo/:page*', { page: 'home' });

Which, really, should work, right?

Nope. When you reload, the Nodejs console is flooded with:

WARN: can/view/stache/mustache_core.js: Unable to find key or helper "page".

Moreover, an asterisk flickers on and off at the end of the URL, the contents of "page" in the ViewModel changes rapidly between 'home' and undefined, and the browser locks up (tried with Chrome and Firefox) after a few seconds.

I have tired removing the * from the route, but this causes /foo/bar/baz to not match while /foo/bar does.

How can I capture the remainder of the URL into the ViewModel?

0

There are 0 answers