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

[BUGFIX beta] remove trailing whitespace from model blueprint #4380

Merged
merged 1 commit into from
May 12, 2016
Merged

[BUGFIX beta] remove trailing whitespace from model blueprint #4380

merged 1 commit into from
May 12, 2016

Conversation

sbatson5
Copy link
Contributor

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.

@sbatson5 sbatson5 changed the title [BUGFIX] remove trailing new lines from model blueprint [BUGFIX] remove trailing whitespace from model blueprint May 11, 2016
@@ -1,5 +1,5 @@
<%= importStatements %>

export default Model.extend({
<%= attrs %>
<%= attrs.length ? ' ' + attrs : '' %>
Copy link
Member

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...

Copy link
Contributor Author

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.

Copy link
Member

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.

@pangratz
Copy link
Member

pangratz commented May 12, 2016

I left a tiny nitpick comment, apart from that: thank you very much for fixing this @sbatson5 🚀 !

Can you also prefix with [BUGFIX beta] so it is ensured that this is fixed in the next beta release (not sure if there will be one before the next stable release, but just to be sure 😉 )?

@sbatson5 sbatson5 changed the title [BUGFIX] remove trailing whitespace from model blueprint [BUGFIX beta] remove trailing whitespace from model blueprint May 12, 2016
@pangratz pangratz merged commit 483648d into emberjs:master May 12, 2016
@pangratz
Copy link
Member

Thank you kindly!

@sbatson5 sbatson5 deleted the BUGFIX-remove-trailing-newline branch September 9, 2016 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants