{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/481","labels_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/481/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/481/comments","events_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/481/events","html_url":"https://github.com/dart-lang/polymer-dart/issues/481","id":85654391,"number":481,"title":"Make it easier to specify polymer expression globals","user":{"login":"DartBot","id":8958862,"avatar_url":"https://avatars.githubusercontent.com/u/8958862?v=3","gravatar_id":"","url":"https://api.github.com/users/DartBot","html_url":"https://github.com/DartBot","followers_url":"https://api.github.com/users/DartBot/followers","following_url":"https://api.github.com/users/DartBot/following{/other_user}","gists_url":"https://api.github.com/users/DartBot/gists{/gist_id}","starred_url":"https://api.github.com/users/DartBot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DartBot/subscriptions","organizations_url":"https://api.github.com/users/DartBot/orgs","repos_url":"https://api.github.com/users/DartBot/repos","events_url":"https://api.github.com/users/DartBot/events{/privacy}","received_events_url":"https://api.github.com/users/DartBot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dart-lang/polymer-dart/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/dart-lang/polymer-dart/labels/PolymerMilestone-Next","name":"PolymerMilestone-Next","color":"ededed"},{"url":"https://api.github.com/repos/dart-lang/polymer-dart/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-06-05T23:14:45Z","updated_at":"2015-06-05T23:14:48Z","closed_at":null,"body":"<a href=\"https://github.com/justinfagnani\"><img src=\"https://avatars.githubusercontent.com/u/522948?v=3\" align=\"left\" width=\"96\" height=\"96\"hspace=\"10\"></img></a> **Issue by [justinfagnani](https://github.com/justinfagnani)**\n_Originally opened as dart-lang/sdk#13470_\n\n----\n\nRight now it's pretty difficult to specify the globals available to expressions in a PolymerElement. This is what's currently required:\n\nclass MyElement extends PolymerElement {\n&nbsp;&nbsp;var \\_mySyntax = new PolymerExpressions(globals: {\n&nbsp;&nbsp;&nbsp;&nbsp;'enumerate': enumerate,\n&nbsp;&nbsp;&nbsp;&nbsp;'appName': 'My App',\n&nbsp;&nbsp;});\n\n&nbsp;&nbsp;DocumentFragment instanceTemplate(Element template) =&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template.createInstance(this, \\_mySyntax);\n}\n\nWe'd like to require less boilerplate and at the same time make it easier to statically analyze so that IDEs could offer warnings and code completion within HTML templates.\n\nA solution could be to allow elements to directly declare their globals, and automatically create a PolymerExpressions object using those globals. To make it more declarative and add type annotations, the globas can be a plain Dart object, instead of a map:\n\nclass MyGlobals {\n&nbsp;&nbsp;List enumerate(List l) =&gt; enumerate(l);\n&nbsp;&nbsp;String appName = 'My App';\n}\n\nclass MyElement extends PolymerElement {\n&nbsp;&nbsp;var globals = new MyGlobals();\n}\n"},"comment":{"url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/comments/109477511","html_url":"https://github.com/dart-lang/polymer-dart/issues/481#issuecomment-109477511","issue_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/481","id":109477511,"user":{"login":"DartBot","id":8958862,"avatar_url":"https://avatars.githubusercontent.com/u/8958862?v=3","gravatar_id":"","url":"https://api.github.com/users/DartBot","html_url":"https://github.com/DartBot","followers_url":"https://api.github.com/users/DartBot/followers","following_url":"https://api.github.com/users/DartBot/following{/other_user}","gists_url":"https://api.github.com/users/DartBot/gists{/gist_id}","starred_url":"https://api.github.com/users/DartBot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DartBot/subscriptions","organizations_url":"https://api.github.com/users/DartBot/orgs","repos_url":"https://api.github.com/users/DartBot/repos","events_url":"https://api.github.com/users/DartBot/events{/privacy}","received_events_url":"https://api.github.com/users/DartBot/received_events","type":"User","site_admin":false},"created_at":"2015-06-05T23:14:48Z","updated_at":"2015-06-05T23:14:48Z","body":"<a href=\"https://github.com/mareksuscak\"><img src=\"https://avatars.githubusercontent.com/u/613647?v=3\" align=\"left\" width=\"48\" height=\"48\"hspace=\"10\"></img></a> **Comment by [mareksuscak](https://github.com/mareksuscak)**\n\n----\n\nThis is by the way already possible through the mixin (although you have to define mixin for every Polymer component but explicit is better than implicit), see here: http://stackoverflow.com/a/25910776/596625"}}