This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Code adapted from | |
https://observablehq.com/@d3/Fradial-tidy-tree | |
https://javadude.wordpress.com/2012/06/20/d3-js-from-tree-to-cluster-and-radial-projection/ | |
https://stackoverflow.com/questions/59783070/d3-v5-radial-tree-cluster | |
--> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>D3.js Radial Tree Example</title> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type iBuilder interface { | |
{{range .Properties -}} | |
set{{if eq .TypeName `int`}}Num{{end}}{{title .Name}}() | |
{{end -}} | |
get{{title .ProductTarget}}() {{.ProductTarget}} | |
} | |
func getBuilder(builderType string) iBuilder { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
{{$target := index .ConcreteTargets 0}} | |
type {{$target}}Builder struct { | |
{{range .Properties -}} | |
{{.Name}} {{.TypeName}} | |
{{end -}} | |
} | |
func new{{title $target}}Builder() *{{$target}}Builder { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"bytes" | |
"fmt" | |
"github.com/Masterminds/sprig" | |
"go/format" | |
"html/template" | |
"log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type {{.ProductTarget}} struct { | |
{{range .Properties -}} | |
{{.Name}} {{.TypeName}} | |
{{end -}} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type director struct { | |
builder iBuilder | |
} | |
func newDirector(b iBuilder) *director { | |
return &director{ | |
builder: b, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
{{$pt:=.ProductTarget}} | |
{{$ct:=.ConcreteTargets}} | |
{{$ps:=.Properties}} | |
{{range $index, $item := $ct}} | |
{{$item}}Builder := getBuilder("{{$item}}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"bytes" | |
"html/template" | |
"os" | |
) | |
type product struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{define "page"}} | |
{{template "header" -}} | |
{{template "content" . -}} | |
{{template "footer" -}} | |
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{define "header" -}} | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> | |
<link rel="stylesheet" href="css/style.css"> | |
<script src="js/script.js" defer></script> |
OlderNewer