{"id":6932,"date":"2014-05-11T17:47:25","date_gmt":"2014-05-11T17:47:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/11\/embedding-a-script-with-a-jsrender-template-collection-of-common-programming-errors\/"},"modified":"2014-05-11T17:47:25","modified_gmt":"2014-05-11T17:47:25","slug":"embedding-a-script-with-a-jsrender-template-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/11\/embedding-a-script-with-a-jsrender-template-collection-of-common-programming-errors\/","title":{"rendered":"Embedding a script with a jsrender template-Collection of common programming errors"},"content":{"rendered":"<p>I would like to use a variable from my jsrender template in order to produce a snippet of javascript, but I can&#8217;t figure out how to place a within my<\/p>\n<p>Hopefully the below is fairly clear. The below code produces an <code>Uncaught SyntaxError<\/code>. If I remove the tags from the embedded script, then it is simply printed onto the page as text.<\/p>\n<p>In the code below, I am trying to generate a div with the id &#8216;chartId&#8217;, and then a script which will fill that div with content, via the MyChart object.<\/p>\n<pre><code>\n    \n        \n            <\/code><\/pre>\n<ul class=\"thumbnails\">{{for graphs}}<\/p>\n<li><code><img loading=\"lazy\" decoding=\"async\" src=\"{{html:url}}\" width=\"190\" height=\"120\" \/><\/code>\n<p><code>{{html:graphTitle}}<br \/>\n{{html:value}}<\/code><\/p>\n<\/li>\n<p>{{\/for}} var chartObj = new MyChart(&#8220;{{html:chartId}}&#8221;); chartObj.render();<\/ul>\n<pre>                           \n        \n        ...\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I would like to use a variable from my jsrender template in order to produce a snippet of javascript, but I can&#8217;t figure out how to place a within my Hopefully the below is fairly clear. The below code produces an Uncaught SyntaxError. If I remove the tags from the embedded script, then it is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6932","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6932"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6932\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}