New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easier to specify polymer expression globals #13470
Comments
Issue #13480 has been merged into this issue. |
Added this to the M8 milestone. |
This comment was originally written by @butlermatt I don't mind globals being a map, it makes it fairly easy to add to it anyways if it was accessible. If I could do something like this: class MyElement extends PolymerElement { String myFunc(s) => s.toUpperCase(); I'm assuming Globals would be a static variable accessible to any custom element within my app (eg any custom element that my app imports) |
I don't think that "globals" should really be global like that, you could really mess with other elements that expect certain globals values. I think the safer way to share a set of globals among elements is to share a superclass or mixin. |
This comment was originally written by @zoechi May I ask what is new? |
Removed Area-Polymer label. |
Removed Library-PolymerExpressions label. |
Removed this from the 1.6 milestone. |
Removed Polymer-P-1 label. |
Removed Polymer-Milestone-Next label. |
This comment was originally written by @mareksuscak This 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 |
This issue has been moved to dart-archive/polymer-dart#481. |
Right now it's pretty difficult to specify the globals available to expressions in a PolymerElement. This is what's currently required:
class MyElement extends PolymerElement {
var _mySyntax = new PolymerExpressions(globals: {
'enumerate': enumerate,
'appName': 'My App',
});
DocumentFragment instanceTemplate(Element template) =>
template.createInstance(this, _mySyntax);
}
We'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.
A 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:
class MyGlobals {
List enumerate(List l) => enumerate(l);
String appName = 'My App';
}
class MyElement extends PolymerElement {
var globals = new MyGlobals();
}
The text was updated successfully, but these errors were encountered: