Search code examples
marionettehandlebars.jsbrunch

handlebars helper: not passing variable


Im using Brunch and I added a custom helper. This works great in normal view templates but in compositeView's itemView template the variable passed to helper is undefined. Without a helper the template is compiled fine.

// Helper
Handlebars.registerHelper 'mny', (val) ->
    val.toString().replace( /\B(?=(\d{3})+(?!\d))/g, " " )

// Example
{{price}} //it works
{{mny price}} //it doesn't

Solution

  • Handlebars needs to know its a function so put a # in front of mny

    {{#mny price}}
    

    hope that fixes it for you