{"action":"created","issue":{"url":"https://api.github.com/repos/nnnick/Chart.js/issues/1772","labels_url":"https://api.github.com/repos/nnnick/Chart.js/issues/1772/labels{/name}","comments_url":"https://api.github.com/repos/nnnick/Chart.js/issues/1772/comments","events_url":"https://api.github.com/repos/nnnick/Chart.js/issues/1772/events","html_url":"https://github.com/nnnick/Chart.js/issues/1772","id":121839246,"number":1772,"title":"Uncaught SyntaxError: Unexpected token =","user":{"login":"levithomason","id":5067638,"avatar_url":"https://avatars.githubusercontent.com/u/5067638?v=3","gravatar_id":"","url":"https://api.github.com/users/levithomason","html_url":"https://github.com/levithomason","followers_url":"https://api.github.com/users/levithomason/followers","following_url":"https://api.github.com/users/levithomason/following{/other_user}","gists_url":"https://api.github.com/users/levithomason/gists{/gist_id}","starred_url":"https://api.github.com/users/levithomason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/levithomason/subscriptions","organizations_url":"https://api.github.com/users/levithomason/orgs","repos_url":"https://api.github.com/users/levithomason/repos","events_url":"https://api.github.com/users/levithomason/events{/privacy}","received_events_url":"https://api.github.com/users/levithomason/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nnnick/Chart.js/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/nnnick/Chart.js/labels/v1.x","name":"v1.x","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-12T07:30:29Z","updated_at":"2015-12-26T23:40:53Z","closed_at":"2015-12-26T21:40:31Z","body":"Experienced similar issues as described in #1116 and #1335.  Version `1.0.2` via cdnjs.  Here was the stack trace:\r\n\r\n```\r\ntmpl                                            @ Chart.js:482\r\nhelpers.template                                @ Chart.js:503\r\nChart.Scale.Chart.Element.extend.buildYLabels   @ Chart.js:1467\r\nChart.Scale.Chart.Element.extend.fit            @ Chart.js:1511\r\nChart.Scale.Chart.Element.extend.initialize     @ Chart.js:1459\r\nChart.Element                                   @ Chart.js:1096\r\nChartElement                                    @ Chart.js:280\r\nChart.Type.extend.buildScale                    @ Chart.js:2728\r\n(anonymous function)                            @ Chart.js:2628\r\nhelpers.each                                    @ Chart.js:200\r\nChart.Type.extend.initialize                    @ Chart.js:2601\r\nChart.Type                                      @ Chart.js:835\r\nChartType                                       @ Chart.js:1058\r\nChart.(anonymous function)                      @ Chart.js:1086\r\n```\r\n\r\nLooking at `tmpl` I see it is a string template function from John Resig's blog.  Debugging I found the offending template.  I had converted the default settings shown in the docs to single quotes incorrectly:\r\n\r\n```js\r\nscaleLabel: '\"<%= value % >\"'\r\n```\r\n\r\nFixing the quotes and the whitespace issue resolved the error.  It is likely that others are experiencing odd syntax errors due to this template function failing on bad templates.  Wrapping the invocation in a try/catch I think is very helpful:\r\n\r\nFrom the current:\r\n```js\r\n// Chart.js @ 503\r\nreturn tmpl(templateString,valuesObject);\r\n```\r\n\r\nTo something along the lines of:\r\n```js\r\ntry {\r\n  return tmpl(templateString,valuesObject);\r\n} catch (e) {\r\n  throw new Error('Cannot create template from string: ' + templateString);\r\n}\r\n```\r\n\r\nRepeating the template string error we now get a much more helpful error:\r\n```\r\nUncaught Error: Cannot create template from string: \"<%= value % >\"   @ Chart.js:506\r\n```\r\n\r\nLooking at the usages of `template()`:\r\n- generateLabels @ Chart.js:513\r\n- generateLegend @ Chart.js:892\r\n- tooltipLabels @ Chart.js:983\r\n- text *(tooltip)* @ Chart.js:1043\r\n- yLabels @ Chart.js:1471 & 1754\r\n- textWidth @ Chart.js:1812\r\n\r\nIt could be extended to take in the config option name it is being used for.  Then the error could also give the property name, something like:\r\n```jsx\r\n// Chart.js @ 503\r\n...\r\nthrow new Error('Invalid \"' + optionName + '\" template string: ' + templateString);\r\n...\r\n// in the browser console\r\nUncaught Error: Invalid \"scaleLabel\" template string: \"<%= value % >\"   @ Chart.js:506\r\n```\r\n\r\nHope this helps, cheers!"},"comment":{"url":"https://api.github.com/repos/nnnick/Chart.js/issues/comments/167371652","html_url":"https://github.com/nnnick/Chart.js/issues/1772#issuecomment-167371652","issue_url":"https://api.github.com/repos/nnnick/Chart.js/issues/1772","id":167371652,"user":{"login":"levithomason","id":5067638,"avatar_url":"https://avatars.githubusercontent.com/u/5067638?v=3","gravatar_id":"","url":"https://api.github.com/users/levithomason","html_url":"https://github.com/levithomason","followers_url":"https://api.github.com/users/levithomason/followers","following_url":"https://api.github.com/users/levithomason/following{/other_user}","gists_url":"https://api.github.com/users/levithomason/gists{/gist_id}","starred_url":"https://api.github.com/users/levithomason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/levithomason/subscriptions","organizations_url":"https://api.github.com/users/levithomason/orgs","repos_url":"https://api.github.com/users/levithomason/repos","events_url":"https://api.github.com/users/levithomason/events{/privacy}","received_events_url":"https://api.github.com/users/levithomason/received_events","type":"User","site_admin":false},"created_at":"2015-12-26T23:40:53Z","updated_at":"2015-12-26T23:40:53Z","body":"Just pointing out this is related but not a duplicate of 1280. 1280 reports that the method is broken in the minified build.  I was not using the minified lib and the method works fine when template strings are valid.\r\n\r\nThis issue is pointing out that the `tmpl` method does not handle errors. It should probably catch bad template strings and throw an error. "}}