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

Update to handlebars v4.0.0 (blocked) #68

Closed
lasse16 opened this issue May 28, 2021 · 10 comments
Closed

Update to handlebars v4.0.0 (blocked) #68

lasse16 opened this issue May 28, 2021 · 10 comments

Comments

@lasse16
Copy link

lasse16 commented May 28, 2021

Environment

  • OS: WSL Ubuntu 20.04
  • Dotter version: 0.12.4

Description

Using the {{#each list} syntax in Handlebar file inserts a new line after each iteration.
Evaluating the same syntax on the Handlebar website does not insert a new line.

Reproduction

In my template file I included:

  {{#each ssh.key-files}}
    ssh-add {{this}};
    {{/#each}}

local.toml contains:

ssh.key-files = [ "~/.ssh/fileA", "~/.ssh/fileB", "~/.ssh/fileC", "~/.ssh/fileD" ]

dotter deploy now renders the template.

Expected behavior

Resulting file section:

ssh-add ~/.ssh/fileA;
ssh-add ~/.ssh/fileB;
ssh-add ~/.ssh/fileC;
ssh-add ~/.ssh/fileD;

Actual behavior

ssh-add ~/.ssh/fileA;

ssh-add ~/.ssh/fileB;

ssh-add ~/.ssh/fileC;

ssh-add ~/.ssh/fileD;

There is a new line inserted between each iteration of the loop.
I created a quick reproduction on the handlebars website with the input data translated to json. There is no new line inserted.

@SuperCuber
Copy link
Owner

IIRC this is already an open issue in the handlebars-rs repository, but if not you should open it there, as I just depend on it :)

I might be using an outdated version where it's fixed though - I'll update and check if that fixes it.

@lasse16
Copy link
Author

lasse16 commented May 29, 2021

I found a PR, which is somewhat related on their Github.

The PR is closing this issue, which is also related to whitespace.

Those two are the only somewhat related mentions on their Github I could find.
My Rust is too bad to understand the changes made in the PR, could you take a look at it @SuperCuber ?

The PR was merged on the fourth of January this year, so it might already be fixed in the most recent version.
If not, I'm going to open an issue on their Github and ask whether it is intended or a bug.

Ohh and thanks for the quick answer and cooperation :).

@lasse16
Copy link
Author

lasse16 commented May 29, 2021

I also figured out a workaround for now. ( Might also be the intended way to solve this problem )

Handlebar offers the ability to control whitespace with the ~ character. Section on the Handlebar website

Inserting this character in the following way, gets rid of the whitespace between each iteration and at the beginning of the loop.

  {{~#each ssh.key-files}}
    ssh-add {{this}};
    {{~/#each}}

The snippet results in the expected result from the opening statement.

@SuperCuber
Copy link
Owner

Yep, this is also what I currently do. (for example with if blocks)

@SuperCuber
Copy link
Owner

Oh just saw the seocnd comment, the second issue is the one I was recalling. I'll check it out.

@SuperCuber
Copy link
Owner

Seems like this is indeed merged to the latest handlebars version 4.0 which got released a couple days ago. However another crate I use called handlebars_misc_helpers did not update to it yet, causing a version mismatch.

I've opened an issue there but for now it's blocking me from upgrading, but when it's fixed it should Just Work™️

@lasse16
Copy link
Author

lasse16 commented May 30, 2021

Ok, thanks for the work :)

@lasse16 lasse16 closed this as completed May 30, 2021
@SuperCuber
Copy link
Owner

I'll reopen this as a reminder to update when the library updates

@SuperCuber SuperCuber reopened this May 30, 2021
@SuperCuber SuperCuber changed the title [BUG] New line in Handlebar #each Update to handlebars v4.0.0 (blocked) May 30, 2021
@Rasmus-Bertell
Copy link

Just a heads up that while your opened issue remains unresolved in handlebars_misc_helpers repo they seems to have updated the handlebars dependency to 4.0 in 0.12.x releases.

@SuperCuber
Copy link
Owner

@RasmusBertell thanks, updated.

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