Skip to content

Commit

Permalink
自动编译模板文件
Browse files Browse the repository at this point in the history
  • Loading branch information
mylxsw committed Sep 14, 2020
1 parent 757ad87 commit 8d9ce61
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 185 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ build-release:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o build/release/adanos-alert-linux cmd/server/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$(LDFLAGS)" -o build/release/adanos-alert-arm cmd/server/main.go

static-gen: build-dashboard
esc-build:
esc -pkg api -o api/static.go -prefix=dashboard/dist dashboard/dist
esc -pkg view -o api/view/views.go -include '.*\.html' -prefix=api/view api/view

static-gen: build-dashboard esc-build

proto-build:
protoc --go_out=plugins=grpc:. rpc/protocol/*.proto
Expand Down
16 changes: 8 additions & 8 deletions api/static.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion api/view/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ type GroupData struct {
PrevOffset int64
}

var defaultTemplateContent string

func init() {
defaultTemplateContent = FSMustString(false, "/groups.html")
}

func GroupView(cc container.Container, data GroupData) (string, error) {
templateContent, err := fileGetContent(filepath.Join(currentPath(), "groups.html"))
if err != nil {
templateContent = defaultMessageViewTemplate
templateContent = defaultTemplateContent
}

return template.Parse(cc, templateContent, data)
Expand Down
175 changes: 0 additions & 175 deletions api/view/template.go

This file was deleted.

Loading

0 comments on commit 8d9ce61

Please sign in to comment.