Skip to content

Instantly share code, notes, and snippets.

@KasperTidemann
Created January 11, 2013 20:31
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 KasperTidemann/4513742 to your computer and use it in GitHub Desktop.
Save KasperTidemann/4513742 to your computer and use it in GitHub Desktop.
Code for {{say ...}} for parsing placeholders etc.
App.registerViewHelper = (name, view) ->
Em.Handlebars.registerHelper name, (property, options) ->
options.hash.textBinding = property.toString()
Em.Handlebars.helpers.view.call this, view, options
App.registerViewHelper 'say', Em.View.extend
tagName: 'span'
template: Em.Handlebars.compile('{{view.say}}')
# Properties:
say: (->
text = @get('text')
placeholder = @get('placeholder')
text = text.replace '{{placeholder}}', placeholder if placeholder?
new Handlebars.SafeString text
).property 'text', 'placeholder'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment