Last Updated: February 25, 2016
·
612
· leighquince

Log within handlbars

When needing to debug within a handlebars template I find it useful to be able to log straight from the template.

first define a helper

Handlebars.registerHelper('HB_log', function(context, options) {
        console.log(context);
     });

then in your template just call it with what you would like to log

{{HB_log this}}

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside