Skip to content

Instantly share code, notes, and snippets.

@theodorton
Last active December 22, 2015 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theodorton/6474283 to your computer and use it in GitHub Desktop.
Save theodorton/6474283 to your computer and use it in GitHub Desktop.
Handlebars li-to helper that let's you wrap a link in a parent element that gets the class name bindings (active, loading etc.) Useful for twitter-bootstrap + ember.js
ul.nav.navbar-nav
= liTo 'index' | Home
= liTo 'about | Index
= liTo 'contact' | Contact
footer
= liTo 'privacy' tagName="p"
| I'm a link wrapped in a p, and when you click on the p you get routed to my link!
Ember.Handlebars.registerHelper 'li-to', (name) ->
options = [].slice.call(arguments, -1)[0]
params = [].slice.call(arguments, 0, -1)
hash = options.hash
hash.disabledBinding = hash.disabledWhen
hash.parameters =
context: this
options: options
params: params
Ember.Handlebars.helpers.view.call this, LinkLiView, options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment