safeJS, but for a block

I’ve got a block of code to support a Google Custom Engine. It is saved in and looks like so:

title = "Search"

(function() {
var cx = '013262903309526573707:i2otogiya2g';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
    '//' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
<gcse:search queryParameterName="q"></gcse:search>

However, when rendere by Hugo, I get errors because the string in the var cx line is modified. I know there is a safeJS function I can pass stuff to - but how do I tell Hugo to not modify this at all.

So, once again, the issue I was having is that I was trying to use code in content, and not layouts. I cut and pasted my code into a shortcode and now it works.

Why can’t we use code in stuff under content?