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

Angle Bracket LinkTo not respecting whitespace formatting #82

Open
tylerturdenpants opened this issue Jul 27, 2019 · 3 comments
Open

Angle Bracket LinkTo not respecting whitespace formatting #82

tylerturdenpants opened this issue Jul 27, 2019 · 3 comments

Comments

@tylerturdenpants
Copy link
Contributor

One of the tests from https://github.com/ember-codemods/ember-angle-brackets-codemod/

Before ember-template-recast (correct)

input: 
{{link-to
  'Users'
  'apps.app.users.segments.segment'
  'all-users'
  (query-params searchTerm=searchTerm)
}}

output: 
<LinkTo
  @route="apps.app.users.segments.segment"
  @model="all-users"
  @query={{hash searchTerm=searchTerm}}
>
  Users
</LinkTo>

After ember-template-recast refactor (incorrect)

input: 
{{link-to
  'Users'
  'apps.app.users.segments.segment'
  'all-users'
  (query-params searchTerm=searchTerm)
}}

output: 
<LinkTo @route="Users" @models={{array 'apps.app.users.segments.segment' 'all-users'}}>Users</LinkTo>
@rwjblue
Copy link
Member

rwjblue commented Jul 30, 2019

I'm not sure this is going to be something we can fix. As far as I understand what is going on, the ember-angle-bracket-invocation-codemod is creating a new ElementNode with new AttrNode's which means we have no original source information that we can use to determine what to do.

I think the best path forward is to provide an API for asking ember-template-recast for an existing nodes "whitespace separator" information and another API to set that info on the newly created node.

What do you think?

@tylerturdenpants
Copy link
Contributor Author

As we discussed, an API would be great, but in the meantime rewriting the new LinkTo with no whitespace separator is fine. We can release an improvement to this scenario as soon as one becomes available

Copy link
Member

rwjblue commented Jul 30, 2019

Sounds good, but I’ll keep this open in the meantime to track the broader api work that needs to happen.

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

No branches or pull requests

2 participants