HandleBars Helper Example

Learn how to leverage the Handlebars helper functions in your Views.

by BinaryAcid

HTML

<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.3.js"></script>
<script type="text/x-handlebars">
    {{#with App.obj}}
        {{view Ember.TextArea valueBinding="location"}}  
        <div>{{{formattedLocation}}}</div>
    {{/with}}
</script>

JavaScript

App = Ember.Application.create();

App.obj = Ember.Object.create({
    location:'Palo Alto',
    
    formattedLocation: function() {
        return this.get('location').replace(/\n\r?/g, '<br />');
    }.property('location').cacheable()
});