INNER CODE UNIT · Go

WriteGraphHTML

pcasteran/terraform-graph-beautifier · cytoscape/writer.go:35

func WriteGraphHTML(writer io.Writer, graph *tfgraph.Graph, options *RenderingOptions) {
	// Get the graph elements JSON.
	var buf bytes.Buffer
	graphWriter := bufio.NewWriter(&buf)
	WriteGraphJSON(graphWriter, graph, options)
	graphWriter.Flush()

	// Load and execute the template.
	b, err := io.ReadAll(options.HTMLTemplate)
	if err != nil {
		log.Fatal().Err(err).Msg("Cannot read HTML template")
	}
	tmpl := template.Must(template.New("cyto-html").Parse(string(b)))
	err = tmpl.Execute(writer, &map[string]interface{}{
		"PageTitle":         options.GraphName,
		"GraphElementsJSON": buf.String(),
	})
	if err != nil {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…