Skip to content

Commit

Permalink
update: move tpl to embed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koooooo-7 committed May 27, 2023
1 parent bb6db3f commit 9a8b8c2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
# IDE
.idea/
.vscode/
examples/
8 changes: 1 addition & 7 deletions templates/base.go → templates/base.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
package templates

// We should check the BaseActions field before call the JSONNotEscapedAction since the BaseActions only exist in RectCharts

var BaseTpl = `
{{- define "base" }}
<div class="container">
<div class="item" id="{{ .ChartID }}" style="width:{{ .Initialization.Width }};height:{{ .Initialization.Height }};"></div>
Expand All @@ -22,5 +17,4 @@ var BaseTpl = `
{{ . | safeJS }}
{{- end }}
</script>
{{ end }}
`
{{ end }}
4 changes: 0 additions & 4 deletions templates/chart.go → templates/chart.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
package templates

var ChartTpl = `
{{- define "chart" }}
<!DOCTYPE html>
<html>
Expand All @@ -14,4 +11,3 @@ var ChartTpl = `
</body>
</html>
{{ end }}
`
4 changes: 0 additions & 4 deletions templates/header.go → templates/header.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
package templates

var HeaderTpl = `
{{ define "header" }}
<head>
<meta charset="utf-8">
Expand All @@ -19,4 +16,3 @@ var HeaderTpl = `
{{- end }}
</head>
{{ end }}
`
4 changes: 0 additions & 4 deletions templates/page.go → templates/page.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
package templates

var PageTpl = `
{{- define "page" }}
<!DOCTYPE html>
<html>
Expand All @@ -22,4 +19,3 @@ var PageTpl = `
</body>
</html>
{{ end }}
`
17 changes: 17 additions & 0 deletions templates/template.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package templates

import _ "embed"

// BaseTpl Should check the BaseActions field before call JSONNotEscapedAction since BaseActions only exist in RectCharts
//
//go:embed base.tpl
var BaseTpl string

//go:embed chart.tpl
var ChartTpl string

//go:embed header.tpl
var HeaderTpl string

//go:embed page.tpl
var PageTpl string

0 comments on commit 9a8b8c2

Please sign in to comment.