I have this in my handlebar template:

<span class="currencyFormatMe">{{_current_price}}</span>

An example of what the loop returns|: Bid: $24000

I'd like to format that with commas and i'm failing.

I have this function which works in the console, but fails when adapted to the codebase with handlebars.

$.fn.digits = function(){ 
    return this.each(function(){ 
        $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
    })
}

And I call it like $("span.currencyFormatMe").digits();

Again it all works in the console, but fails when adapted. Any pointers are very welcome

Tried it with a registerhelper:

Handlebars.registerHelper('formatCurrency',
    $.fn.digits = function(){ 
        return this.each(function(){ 
            $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
        })
    }
);

Calling:

{{formatCurrency _current_price}}
Edit
Report