What is the best method to insert a javascript snippet into a template for Golang using the Beego framework?
Currently, I am just adding data to a template:
c.Data["Javascript"] = JavasciptStringObject
And in a script.tpl file adding insertion points:
var canvas = new fabric.Canvas('c');
canvas.setHeight(571); //todo: Set to height of image
canvas.setWidth(991);
{{.JavaScript}}
The problem is that it escapes the quotation marks from the string, rather than injecting directly in:
var canvas = new fabric.Canvas('c');
canvas.setHeight(571);
canvas.setWidth(991);
"var path = new fabric.Path('M 617 141 L 606 126M 606 126 L 604 127 z', { stroke: 'red', strokeWidth: 2, fill: false, originX: 'left', originY: 'top',});canvas.add(path); "
Some useful resources include Golang HTML Templating Doc, which apparently Beego models: https://golang.org/pkg/html/template/
And this stack overflow seems to be getting closer, I don't think this will work with Beego: Go lang templates: always quotes a string and removes comments