No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

46 líneas
1.1KB

  1. package template
  2. import (
  3. "fmt"
  4. "git.wtrh.nl/patterns/gopatterns/pkg/pattern/text"
  5. "slices"
  6. "strings"
  7. )
  8. type Information struct {
  9. Point `yaml:",inline"`
  10. Anchor string `yaml:"anchor"`
  11. }
  12. func (t Template) createInformation(req request) (text.Text, error) {
  13. templatePanel, ok := t.Panels[req.panel]
  14. if !ok {
  15. return text.Text{}, ErrPanelNotFound
  16. }
  17. dims := make([]string, 0, len(req.dimensions))
  18. for _, dimension := range req.dimensions {
  19. dims = append(dims, fmt.Sprintf(" %s: %.1f cm", dimension.Name, dimension.Value/10))
  20. }
  21. slices.Sort(dims)
  22. dims = append([]string{
  23. "For: " + req.owner,
  24. "Pattern: " + startCase(t.Name),
  25. "Panel: " + startCase(req.panel),
  26. "Hem allowance: " + templatePanel.Allowances.Hem,
  27. "Seam allowance: " + templatePanel.Allowances.Seam,
  28. "\nMeasurements:",
  29. }, dims...)
  30. templatePanel.Points["_information"] = templatePanel.Information.Point
  31. point, err := t.getOrCreatePoint("_information", req, 0)
  32. if err != nil {
  33. return text.Text{}, err
  34. }
  35. info := text.NewText(point.Position(), templatePanel.Information.Anchor, strings.Join(dims, "\n"))
  36. return info, nil
  37. }