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

Handlebars {{else if}} and {{each}}{{else}} not formatting #781

Closed
janwerkhoven opened this issue Feb 4, 2016 · 7 comments
Closed

Handlebars {{else if}} and {{each}}{{else}} not formatting #781

janwerkhoven opened this issue Feb 4, 2016 · 7 comments

Comments

@janwerkhoven
Copy link

Hi,

There are couple of Handlebar blocks which do not indent as expected. Using JS Beautify (only option).

In Ember the {{else if}} block:

// Expected

{{#if isValid1}}
  <p>Is valid 1</p>
{{else if isValid2}}
  <p>Is valid 2</p>
{{else}}
  <p>Is neither</p>
{{/if}}

// What happens instead

{{#if isTrue1}}
  <p>Is valid 1</p> {{else if isTrue2}}
  <p>Is valid 2</p>
{{else}}
  <p>Is neither</p>
{{/if}}

Also in Ember the {{else}} blocks within {{each}} blocks:

// Expected

{{#each clinics as |clinic|}}
  <p>{{clinic.name}}</p>
{{else}}
  <p>Unfortunately no clinics found.</p>
{{/each}}

// What happens instead

{{#each clinics as |clinic|}}
  <p>{{clinic.name}}</p>
  {{else}}
    <p>Unfortunately no clinics found.</p>
{{/each}}

Atom debug log: https://gist.github.com/janwerkhoven/9a20c4b21b2ee3ce0555

Love your package 👍

@prettydiff
Copy link
Collaborator

I think Pretty Diff is the default beautifier for Handlebars templates. When I supply the code samples to http://prettydiff.com the result looks correct. I will continue to look at this.

@janwerkhoven
Copy link
Author

There is only 1 option ...

screen shot 2016-02-04 at 2 03 03 pm

@prettydiff
Copy link
Collaborator

I am alerting @bitwiseman that there may be an issue with JS Beautify. I will also work on adding Pretty Diff as a secondary beautifier for Handlebars.

@prettydiff
Copy link
Collaborator

@Glavin001 Why is Handlebars not listing Pretty Diff as a beautifier? It appears to be properly indicated in the code: https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/prettydiff.coffee#L72

@bitwiseman
Copy link
Contributor

@prettydiff, @janwerkhoven - handlebars support is very spotty in beautifier.
https://github.com/beautify-web/js-beautify/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+handlebars

Please file this as an issue of there. Thanks!

@prettydiff
Copy link
Collaborator

Done: beautifier/js-beautify#870

@stale
Copy link

stale bot commented Nov 4, 2017

This issue has been automatically marked as stale because it has not had recent activity. If this is still an issue, please add a comment. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 4, 2017
@stale stale bot closed this as completed Nov 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants