-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support assignment of attribute litterals via interpolation #106
Comments
The problem with the Example: <div foo-bar.bind="baz & attr"></div> "foo-bar" will be translated to "fooBar". |
I could really do with this feature, and just so there is a link to the use case which started it all: |
Here's how to extend the binding syntax with a import {SyntaxInterpreter} from 'aurelia-templating-binding';
import {BehaviorInstruction} from 'aurelia-templating';
import {BindingExpression, BindingBehavior} from 'aurelia-binding';
SyntaxInterpreter.prototype.attr = function(resources, element, info, existingInstruction, context) {
const instruction = existingInstruction || BehaviorInstruction.attribute(info.attrName);
const expression = new BindingBehavior(this.parser.parse(info.attrValue), 'attr', []);
instruction.attributes[info.attrName] = new BindingExpression(
this.observerLocator,
info.attrName,
expression,
info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName, context),
resources.lookupFunctions
);
return instruction;
} Usage: |
a lot of third-party functionality is achieved via adding attributes to an element. Some of these attribute values can be quite large and/or can be best assigned via interpolation. It would be useful to support this for the sake of better integration with standards + third-party libraries.
As per @jdanyow's suggestion, introduciton of
.attr
binding could facilitate these use cases.For example:
would result in the outcome (assuming
current = 0
):The text was updated successfully, but these errors were encountered: