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

Wrap function is droping characters at wrap point #47

Closed
cp-richard opened this issue Jun 14, 2017 · 5 comments
Closed

Wrap function is droping characters at wrap point #47

cp-richard opened this issue Jun 14, 2017 · 5 comments

Comments

@cp-richard
Copy link

Wrap and WrapWith both lose the character at the wrap point

Test example :


import (
  "github.com/Masterminds/sprig"
  "html/template"
  "bytes"
)

func main() {
  // The template
  tpl := "Word Wrap Test\n{{.Name | wrap 11 }}\n"

  // The values to pass to the template
  vars := map[string]string{"Name": "123456789_123456789_123456789_123456789_1234567890"}

  // Compile the template
  t := template.Must(template.New("example").Funcs(sprig.FuncMap()).Parse(tpl))

  // Run the template, copying the output to the buffer.
  var b bytes.Buffer
  err := t.Execute(&b, vars)
  if err != nil {
      panic(err)
  }
  print(b.String())
}

Output showing issue - in the first split line 1 is lost and 2 starts the second line, and so on :

Word Wrap Test
123456789_
23456789_1
3456789_12
456789_123
567890
@technosophos
Copy link
Member

This appear to be an issue with goutils.

@mattlorimor
Copy link
Contributor

I have a PR to goutils that should hopefully fix this: Masterminds/goutils#26

@mattlorimor
Copy link
Contributor

FYI, @kti-richard

Since Masterminds/goutils#26 was merged, this bug should be taken care of once if a new release of goutils is cut and then consumed by sprig.

@mattlorimor
Copy link
Contributor

This should be resolved as of https://github.com/Masterminds/sprig/releases/tag/v2.17.0.

@mattfarina
Copy link
Member

This is resolved so closing.

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

4 participants