Hallo.
linkTo
will likely be getting some enhancements shortly. Just wanted to get people’s thoughts / potential objections on them
Unquoted route arg will perform a property lookup
Presently interchangeable:
{{#linkTo foo}}Foo{{/linkTo}}
{{#linkTo 'foo'}}Foo{{/linkTo}}
But shortly, the first one will perform a property lookup for the foo
property on the present template context. So if your controller defines foo: 'index'
, then the linkTo will generate a link to index. If foo changes, the link will be updated.
This will certainly break many apps, but even though it’s unfortunately made its way into documentation (I’m to blame in some cases), quoteless parameters were never intended to be wholesale treated like strings; it’s an accident of somewhat undefined behavior that they’ve been treated this way for this long. So this applies to things like {{action foo}}
as well, though that may be addressed in a PR separate from the one that facelifts linkTo
.
So, how should we proceed? We could:
- Do nothing. Just make the change, publish an RC blog post explaining what’s up
- Make the new behavior opt-in via a temporary flag.
- Make the new behavior opt-out via a temporary flag.
- Something else?
String/Number params for linkTo
/ transitionTo
treated as URL params
Presently, both linkTo 'routeName' foo bar
and transitionTo('routeName', foo, bar)
will supply contexts to the transition to ‘routeName’ for the leaf-most dynamic routes, but this requires having an object for the route you’d like to transition to. A major missing use case is when all you have is the id, and you’d like to use the destination route’s model
hook with that id to perform the transition.
I propose that if the contexts you provide is a number or a string, then it’s assumed to be parameters for dynamic segments, e.g. you could transition to ‘/posts/:post_id’ via transitionTo('posts.show', 5)
or transitionTo('posts.show', '5')
. This would mean that you can’t just use a string or a number as a route’s model, but I don’t anyone really does that anyway, and even if they did it’d be trivial to just wrap it in an object.
Thoughts on all the above?