-
Notifications
You must be signed in to change notification settings - Fork 32
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
Preserve formatting #1
Comments
Accordingly to an answer by @ef4 on discuss.emberjs.com writing "there’s not a handlebars AST printer that does a good job of preserving formatting. That is the main blocker to writing HBS code mods." It's from October 2018, so maybe there were some improvements in the tool chain. |
Another option would be not to preserve the format but just apply the coding style used in guides? Not quite sure if this is easier but having a code mod that also fixes all template linting errors sounds quite nice. 😆 |
You could also use Prettier to format using the glimmer parser :) |
Thanks @Alonski it works, but it entirely reformats the whole file though the formatting is pretty. |
@rajasegar-c I have been working on transitioning to ember-template-recast and have a near 1 to 1 transform as the original transform but I’m unsure how to write test for it. Could you help me with that? @rwjblue is there a way to test using the currrent fixtures? |
@tylerturdenpants As far as I know, the tests should work fine, since you will be using a different parser here for the transform, it should not affect the tests I guess |
@tylerturdenpants do you have a branch with the ember-template-recast to share? I'd be curious to see the results it gives. I've been playing around with Prettier handlebars support and it still seems a bit experimental to me as it gives some strange formatting results. I wonder if using Prettier formatting out-of-the-box could be a blocker for folks to adopt using this codemod? |
What I have been able to do is retrofit the |
@tylerturdenpants yeah that would be great 👍 I'm curious to see the difference between the formatting. |
Use my branch https://github.com/tylerturdenpants/ember-angle-brackets-codemod/tree/use-etr
|
@tylerturdenpants doesn't look like the ember-template-recast (ETR) version is as stable as I'd hoped. I've never used ember-template-recast before so maybe I'm misunderstanding the // before
{{ic-button
label='Save photo'
type='primary'
onClick=(action 'saveAdminAvatar')
inLeftList=true
}}
// ember-template-recast
// 1) Doesn't self-close non-block component 2) places all properties on the same line
<IcButton @label="Cancel" @type="secondary" @onClick={{action "removeFile"}} @inLeftList={{true}}></IcButton>
// current master + prettier
<IcButton
@label="Save photo"
@type="primary"
@onClick={{action "saveAdminAvatar"}}
@inLeftList={{true}}
/> I've also found some bugs where it deletes closing Edit: an example of deleting closing //before
{{#if autoHeight}}
<div></div>
{{else}}
{{#vertical-collection rows as |row|}}
{{ic-legacy-table-row
columns=fullColumnsWithSettings
row=row
tableActions=tableActions
updateWidths=(action updateWidths)
}}
{{/vertical-collection}}
{{/if}}
// ember-template-recast
// closing if deleted and also the inner-component isn't converted
{{#if autoHeight}}
<div></div>
{{else}}
<VerticalCollection as |row|>
{{ic-legacy-table-row columns=fullColumnsWithSettings row=row tableActions=tableActions updateWidths=(action updateWidths)}}
</VerticalCollection> |
resolved by #97 |
Currently, the codemod is not preserving the code format properly, there are some missing indentations and line breaks. Need to fix this.
The text was updated successfully, but these errors were encountered: