[feature request] - path helper - similar to more-routing's urlFor method
It would be nice if there was a method to generate the proper href depending on hash or pushstate option.
https://github.com/PolymerLabs/more-routing#urlfor (for reference)
Could you add a sample snippet to show how this property is calculated? E.g. if you use the method, what is the expected outcome and how is it used?
I now realize the referenced document is not the best example of what I asked for because of a different design followed in more-routing
<a href="{{ carbonRoute.pathToUrl('/path') }}">Path</a>
would result in: (depending on what mode was being used)
<a href="/path">Path</a>
or
<a href="#/path">Path</a>
And I would hope this could be expanded work similar to more-routing.urlFor and calculate URLs for patterns either by referencing the related path (not likely to be very functional due to sub routes being in ShadowDOM elsewhere) or by accepting the path pattern that is used by the route instead. so....
<a href="{{ carbonRoute.pathToUrl('/users/:user', {user: 1}) }}">User 1</a>
would result in: (depending on what mode was being used)
<a href="/users/1">User 1</a>
or
<a href="#/users/1">User 1</a>
This is a nice feature to have, especially for a reusable routable element. The tricky thing here is that this requires something of global knowledge. You need to know how the carbon-location is configured as well as every carbon-route element in the path from that carbon-location to the final carbon-route element that you want to generate a link for.
@rictic That's true but the alternative is to hard code the URLs everywhere or pass around your own global object.
@robdodson This is true. Link generation getting significantly harder appears to be part of the trade off for modular and decentralized routing.
👍! I would like to remove hard code URLs in the PSK2.