PolymerElements / app-route

A modular client-side router
https://www.polymer-project.org/1.0/articles/routing.html
146 stars 66 forks source link

Possibility to add optional parameters #186

Open jlramosr opened 7 years ago

jlramosr commented 7 years ago

We have the possibility to add optional parameters on the pattern attribute with the ? character at the end. In this example:

    <app-route
      active="{{active}}"
      route="{{route}}"
      pattern="/client/:id?"
      data="{{routeData}}"
      tail="{{subroute}}"></app-route>

The path /client matches the route, setting routeData.id to undefined and active to true. If pattern would be /client/:id, this path wouldn't matches the route. With the pattern of the example above, the path /client/c123 also matches the route, with routeData.id equal to c123.

A more complicated example would be the same app-route element with pattern attribute pattern="/client/:id?/:action?". The paths /client, /client/, /client/c123, /client/123/overview also matches the route. Supossing second path (/client/), routeData would be {'id': '', 'action': undefined}

This feature also works with fixed patterns without parameters (i.e. pattern="/client/list?").

googlebot commented 7 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


jlramosr commented 7 years ago

I signed it!

2017-03-16 15:08 GMT+01:00 googlebot notifications@github.com:

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

đź“ť Please visit https://cla.developers.google.com/ https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PolymerElements/app-route/pull/186#issuecomment-287068074, or mute the thread https://github.com/notifications/unsubscribe-auth/AF3lkrmnaRYlytsT37GafEw_1F9J8sAxks5rmUJ3gaJpZM4MfWaJ .

-- José Luis Ramos http://google.com/+JoséLuisRamosRomero www.futbolypensamiento.com

googlebot commented 7 years ago

CLAs look good, thanks!

jlramosr commented 7 years ago

Of course, I get on to it now!

2017-03-16 15:14 GMT+01:00 Tim van der Lippe notifications@github.com:

@TimvdLippe requested changes on this pull request.

This would be really cool! Could you add tests to verify that this is working as intended?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PolymerElements/app-route/pull/186#pullrequestreview-27347684, or mute the thread https://github.com/notifications/unsubscribe-auth/AF3lkkJoYeK0VjJ6PWPnQz9k5YLB26bgks5rmUOsgaJpZM4MfWaJ .

-- José Luis Ramos http://google.com/+JoséLuisRamosRomero www.futbolypensamiento.com

Oupsla commented 7 years ago

Any news about this feature ?

ggirard07 commented 7 years ago

Optional parameters will be so cool and really help the routing process. Any news on whether this PR can be accepted?