Created
January 11, 2013 20:31
-
-
Save KasperTidemann/4513742 to your computer and use it in GitHub Desktop.
Code for {{say ...}} for parsing placeholders etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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