I'm trying to write a handlebars helper that spits out the current url query string. I will then use that query string to populate a template. I'm using assemble to do the html file generation.
My urls look like this: groups/group-details/?id=1
and I want to get at the id value.
Here is my helper:
Handlebars.registerHelper('currentId', function() {
return document.location.search.split('?')[1].split('=')[1];
});
And I am calling it in my .hbs template like this:
{{currentId}}
I am expecting it to just spit out 1
in this example but nothing is shown.
Where am I going wrong?
- Edit -
Digging around in the web inspector console shows my helper is registered but if I put a breakpoint on the return statement, it never gets hit. I assume the helper just isn't being 'executed'.