5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 09:00:38 +08:00
wails/utils.go
Lea Anthony 27f852ac6a
ignoring findstring errors for bridge mode
refactored build mode strings
2019-02-16 06:58:30 +11:00

30 lines
571 B
Go

package wails
import (
"log"
"strings"
"github.com/wailsapp/wails/cmd"
"github.com/gobuffalo/packr"
)
func escapeJS(js string) (string, error) {
result := strings.Replace(js, "\\", "\\\\", -1)
result = strings.Replace(result, "'", "\\'", -1)
result = strings.Replace(result, "\n", "\\n", -1)
return result, nil
}
// BoxString wraps packr.FindString
func BoxString(box *packr.Box, filename string) string {
result, err := box.FindString(filename)
if err != nil {
if BuildMode == cmd.BuildModeBridge {
return ""
}
log.Fatal(err)
}
return result
}