-
-
Save Ethanhackett/943de9232d8cfd5d3db5 to your computer and use it in GitHub Desktop.
--- | |
layout: default.hbs | |
url: '?utm_source=Source&utm_medium=Medium&utm_term=Term&utm_content=Content&utm_campaign=Name' | |
--- | |
{{> global-header }} | |
<a href="http://www.domain.com/{{url}}">Click Me</a> | |
or | |
{{> partial-with-anchor }} | |
{{> global-footer }} |
@Ethanhackett, try using this just to see if it's a handlebars escaping issue:
module.exports.register = function (Handlebars, options) {
Handlebars.registerHelper('url', function (str) {
return new Handlebars.SafeString(str);
});
};
Keep in mind that if you call the helper inside a block (e.g. {{#foo}} {{url url}} {{/foo}}
, you will need to tell handlebars that you want the same scope as the "parent" block, so in the url helper you would do {{url ../url}}
to go up a level. Hope that makes sense.
(you can stop there, but in case you're curious, by default handlebars tries to prevent unsafe code from rendering without your knowledge, which is probably the cause of the issue you're having - technically it's a good thing. SafeString
is how you tell handlebars that you don't want its protection)
that's a good question @doowb, might make this easier to solve if it is
@doowb yeah if I strip out some of the other processes it looks correct with {{{url}}} and {{& url}}. I think it's grunt-inline-css that's messing with the ampersands...
Are you using something after assemble in your build process? When I use
{{{url}}}
it doesn't escape the&
.