Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions text/0000-url-for.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
- Start Date: 2015-09-12
- RFC PR: (leave this empty)
- Ember Issue: (leave this empty)

# Summary

This RFC proposes the extraction of a new `url-for` helper from `link-to`.

# Motivation

Decomposing `link-to` into a set of helpers will allow us to simplify its internals while providing new low level primitives for use in performance sensitive applications. `url-for`, the first of these extracted helpers, will allow for simple URL rendering in an Ember application. Extracting separate helpers for dealing with link classes will be suggested in a future RFC.

This proposal would also allow plain URLs to be used within an Ember application without triggering an application reload. For example, a url such as `/about` could be used within a template or helper.

# Detailed design

The `url-for` helper would provide a similar interface to the `link-to` helper in block form:

```
{{#link-to 'photo.comment' 5 primaryComment}}
Main Comment for the Next Photo
{{/link-to}}
```

The `url-for` equivalent would be:

```
<a href="{{url-for 'photo.comment' 5 primaryComment}}">
Main Comment for the Next Photo
</a>
```

The `url-for` helper would simply render the URL, no component is needed.

An additional click handler would be setup in [EventDispatcher](https://github.com/emberjs/ember.js/blob/master/packages/ember-views/lib/system/event_dispatcher.js) to capture any clicks on anchors within the ember application. Any anchor URL recognized by the router will be handled by it.

# Drawbacks

This expands the API surface area of Ember.js by introducing a new helper. One additional global event handler would be required.

# Alternatives

The existing [`href-to` addon](https://github.com/intercom/ember-href-to) provides this capability and applications can currently opt-in if they desire.

# Unresolved questions

Is there a better name than `url-to`? What other features of `link-to` should we also support (eg. `replace=true`)?