-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[BUGFIX beta] remove trailing whitespace from model blueprint #4380
[BUGFIX beta] remove trailing whitespace from model blueprint #4380
Conversation
@@ -1,5 +1,5 @@ | |||
<%= importStatements %> | |||
|
|||
export default Model.extend({ | |||
<%= attrs %> | |||
<%= attrs.length ? ' ' + attrs : '' %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally think that using an if
here, might make this more readable:
export default Model.extend({
<% if (attrs) { %>
<%= attrs %>
<% } %>
});
What do you think?
Another possibility would be to prepend the empty string within blueprints/model/index.js
. We are already doing that for the needs
statement, so I think this would be fine for attrs
too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pangratz Thanks for the feedback!
The problem I run into with the if
condition is that if I do pass in attrs
ember g model foo --attrs name, title
I get empty lines surrounding them:
export default Model.extend({
name,: attr(),
title: attr()
});
The ternary doesn't have that issue. I tried the suggestion found here: #4306 (comment) using -%>
but received an Unexpected token
error no matter where I used it (both for the closing if
and <%= attrs -%>
).
I saw that ternary used here https://github.com/emberjs/data/blob/master/blueprints/model-test/qunit-files/tests/unit/__path__/__test__.js#L5 so went that route. But I agree that it isn't that readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. Thanks for the heads up @sbatson5. Let's leave it then the way it is, we can always change this later on.
I left a tiny nitpick comment, apart from that: thank you very much for fixing this @sbatson5 🚀 ! Can you also prefix with |
Thank you kindly! |
Addresses: #4306
This ensures that if attrs are present when generating a model, we indent them properly. If no attrs are present, there should be no trailing whitespace.