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

Replacement in partial removes a newline #86

Open
noel-yap opened this issue Feb 3, 2023 · 0 comments
Open

Replacement in partial removes a newline #86

noel-yap opened this issue Feb 3, 2023 · 0 comments

Comments

@noel-yap
Copy link

noel-yap commented Feb 3, 2023

Test:

func TestMustacheRenderPartials(t *testing.T) {
	expected := "header\n\n\tline 1\n\tline 2\n\nfooter\n"

	staticProvider := &mustache.StaticProvider{
		Partials: map[string]string{
			"body": strings.Join([]string{
				"\tline 1",
				"\tline 2",
			}, "\n"),
		},
	}

	actual, err := mustache.RenderPartials(
		"header\n\n{{> body}}\n\nfooter\n",
		staticProvider,
		map[string]string{},
	)

	assert.NoError(t, err)
	assert.Equal(t, expected, actual)
}

I'm expecting there to be two newlines after replacing {{> body}} in the template but there's only one newline after that replacement.

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

1 participant