I'm getting some html from node-request and I want to place that html into my javascript code as strings:
<div id='frontpage'><div set-href="'/user/' + (user | encodeURIComponent)">userlink</div></div>
The goal is to get an output like this for angularjs:
var createCache = function (path, template) {
return "\n $templateCache.put('" + path + "',\n '" +template + "'\n );\n";
}
This code is too naive, there are issues with quotes and other potential problems. How could it be done correctly? Is there a way to get the string from node-request itself? Thanks.
escape()
method? – Nick Dugger May 8 at 14:29\'
not%27
– Harry May 8 at 14:31.replace(/"/g, "\"")
or some regex, which I never wrapped my head around, myself. – Nick Dugger May 8 at 14:32