generated from VLADIMIR/template
add format string
This commit is contained in:
@@ -2,4 +2,5 @@ package formatter
|
||||
|
||||
type IFormatter interface {
|
||||
FormatText(text string) string
|
||||
FormatString(text string) string
|
||||
}
|
||||
|
||||
@@ -40,3 +40,11 @@ func (s *service) FormatText(text string) string {
|
||||
}
|
||||
return res.String()
|
||||
}
|
||||
|
||||
func (s *service) FormatString(text string) string {
|
||||
l := strings.TrimSpace(text)
|
||||
if strings.HasPrefix(l, "--") {
|
||||
l = strings.Replace(l, "--", "—", 1)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ func (s *StoryService) updatePlace(ctx context.Context, code string, node *Graph
|
||||
if s.story.Places[i].Code == code {
|
||||
s.story.Places[i] = models.NewPlace(
|
||||
node.Code,
|
||||
node.Name,
|
||||
s.formatter.FormatString(node.Name),
|
||||
s.formatter.FormatText(node.Text),
|
||||
models.WithPlaceImage(node.Image),
|
||||
models.WithPlaceApplication(s.getApplications(node)...),
|
||||
@@ -189,7 +189,7 @@ func (s *StoryService) updatePlace(ctx context.Context, code string, node *Graph
|
||||
if s.story.Places[i].Code == node.Code {
|
||||
s.story.Places[i] = models.NewPlace(
|
||||
code,
|
||||
node.Name,
|
||||
s.formatter.FormatString(node.Name),
|
||||
s.formatter.FormatText(node.Text),
|
||||
models.WithPlaceImage(node.Image),
|
||||
models.WithPlaceApplication(s.getApplications(node)...),
|
||||
@@ -208,7 +208,7 @@ func (s *StoryService) getApplications(node *GraphNode) []*models.Application {
|
||||
nodeApplications = append(
|
||||
nodeApplications,
|
||||
&models.Application{
|
||||
Name: application.Name,
|
||||
Name: s.formatter.FormatString(application.Name),
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -222,7 +222,7 @@ func (s *StoryService) getDoors(node *GraphNode) []*models.Door {
|
||||
nodeDoors,
|
||||
&models.Door{
|
||||
Code: door.Code,
|
||||
Name: door.Name,
|
||||
Name: s.formatter.FormatString(door.Name),
|
||||
Show: door.Show,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user