Splat routes allow you to do a catch all to catch 1 or more segments at the end of the route. If you want to have all of your routes defined from a CMS, then you can use app/Route.SPLAT_.elm. That will match any URL except for the root route (/). page
You can have any number of static segments and dynamic segments before the SPLAT_ and it will match as usual. For example, app/Route/City/SPLAT_.elm could be used to match the following:
URL | RouteParams |
---|---|
/city/paris | { splat = ( "paris", [] ) } |
/city/france/paris | { splat = ( "france", [ "paris" ] ) } |
/city/us/california/los-angeles | { splat = ( "us", [ "california", "los-angeles" ] ) } |
The *splat route convention enables you to define a route that can get anything written after the * sign as an action parameter. For example, the route “car/*imagePath” will match the http://mywebsite/#car/images/bmw. jpg URL. The action in the previous example should include an imagePath parameter. Listing 5-27 shows how to configure a route using *splat.
FINK, Gil and FLATOW, Ido, 2014. Pro single page application development: using Backbone.js and ASP.NET. New York: Apress. The expert’s voice in Web development. ISBN 978-1-4302-6673-0, p. 87.
~
DOT FROM lambda-browsing