Skip to content
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 v-get inside element note attribute strings #54

Merged
merged 1 commit into from
Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ import User from '../models/user';
export default Ember.Route.extend({
model() {
var container = this.get('container');
return User.create({ container })
return User.create({ username: 'John', container })
}
});
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import User from '../models/user';
export default Ember.Route.extend({
model() {
var container = this.get('container');
return User.create({ container })
return User.create({ username: 'John', container })
}
});
```
Expand Down
12 changes: 10 additions & 2 deletions htmlbars-plugins/v-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,24 @@ VGet.prototype.processNodeHash = function(node) {
};

/**
* <button type="submit" disabled={{v-get model 'isInvalid'}}>Submit</button>
* <button type="submit" disabled={{v-get model 'isInvalid'}}>Submit</button> (node.attributes)
* <div class="form-group {{if (v-get model 'isInvalid') 'has-error'}}">
* @param {AST.Node} node
*/
VGet.prototype.processNodeAttributes = function(node) {
var i;
if (node.attributes) {
for (var i = 0; i < node.attributes.length; i++) {
for (i = 0; i < node.attributes.length; i++) {
var attr = node.attributes[i];
this.processNode(attr.value);
}
}

if (node.parts) {
for (i = 0; i < node.parts.length; i++) {
this.processNode(node.parts[i]);
}
}
};


Expand Down
9 changes: 9 additions & 0 deletions tests/integration/helpers/v-get-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,12 @@ test('element node attribute', function(assert) {
assert.equal(this.$().text().trim(), 'Button');
assert.equal(this.$('button').prop('disabled'), true);
});

test('element node attribute in class string', function(assert) {
assert.expect(3);

this.render(hbs`<span class="base {{if (v-get model 'isInvalid') 'has-error'}}">Text</span>`);
assert.equal(this.$().text().trim(), 'Text');
assert.equal(this.$('span').hasClass('base'), true, 'base class present');
assert.equal(this.$('span').hasClass('has-error'), true, 'error class present');
});