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

Vanishing newlines #457

Closed
vojtechkral opened this issue Jul 22, 2021 · 6 comments
Closed

Vanishing newlines #457

vojtechkral opened this issue Jul 22, 2021 · 6 comments

Comments

@vojtechkral
Copy link

vojtechkral commented Jul 22, 2021

I think the change at #404 might've been too aggressive, given a template like this:

      {{~#if condition}}
        foo
        bar
      {{/if}}
    baz

I get no newline between bar and baz anymore. I believe there should be one. A workaround is to add a comment right after the closing if, ie. {{/if}}{{!}}.
But for now I think I'll hold the update to 4.x ...

This is probably tricky to solve correctly.

@vojtechkral
Copy link
Author

vojtechkral commented Jul 22, 2021

Similar issue is with inline partials.
This:

{{#*inline "foo"}}foo
{{/inline}}
{{> foo}}
{{> foo}}
{{> foo}}

Should render the foos with newlines inbetween (currently that is not the case).

vojtechkral added a commit to vojtechkral/bard that referenced this issue Jul 22, 2021
This reverts commit 7622d05.
This is dure to a whitespace parsing issue with hbs 4.x
sunng87/handlebars-rust#457
sunng87 added a commit that referenced this issue Jul 22, 2021
sunng87 added a commit that referenced this issue Jul 22, 2021
@sunng87
Copy link
Owner

sunng87 commented Jul 25, 2021

@vojtechkral for case

      {{~#if condition}}
        foo
        bar
      {{/if}}
    baz

I cannot reproduce the issue as you described for newline between bar and baz. You can check the commit to see if it matches your scenario. However there is a bug with additional newline added ahead of foo and it's fixed in #458

I will be digging into your second case soon

@sunng87
Copy link
Owner

sunng87 commented Jul 25, 2021

@vojtechkral could you help to verify it's handlebars 4.1 on which these issues happened? Changes in #404 could have affected your cases but should have been fixed in 4.1 with #448 . Although I managed to fix some corner cases in #458 but none of them are related to your scenario.

@vojtechkral
Copy link
Author

@sunng87 I'll try

@vojtechkral
Copy link
Author

@sunng87 Yeah, it looks like the if case is gone or wasn't there in the first place, I think I might've relied on pre- #458 behvaiour. Sorry about that.

The inline case is still there it seems, in this file the inline i-break doesn't work anymore on 4.1

@vojtechkral
Copy link
Author

Hm... however, it looks like the behavior is the same now as in JS handlebars. So, looks like I was relying on nonstandard thing there as well.
Ok, I'll close the bug and update my code.

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