title: Insert JavaScript Snippet Inside Template with Beego/GoLang
body: <p>What is the best method to insert a javascript snippet into a template for Golang using the Beego framework?</p>
  
  <p>Currently, I am just adding data to a template:</p>
  
  <pre><code>c.Data["Javascript"] = JavasciptStringObject
  </code></pre>
  
  <p>And in a script.tpl file adding insertion points:</p>
  
  <pre><code> var canvas = new fabric.Canvas('c');
   canvas.setHeight(571); //todo: Set to height of image
   canvas.setWidth(991);
   {{.JavaScript}}
  </code></pre>
  
  <p>The problem is that it escapes the quotation marks from the string, rather than injecting directly in: </p>
  
  <pre><code>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); "
  </code></pre>
  
  <p>Some useful resources include Golang HTML Templating Doc, which apparently Beego models: <a href="https://golang.org/pkg/html/template/" rel="nofollow noreferrer">https://golang.org/pkg/html/template/</a></p>
  
  <p>And this stack overflow seems to be getting closer, I don't think this will work with Beego: <a href="https://stackoverflow.com/questions/14226416/go-lang-templates-always-quotes-a-string-and-removes-comments">Go lang templates: always quotes a string and removes comments</a></p>