Code

API

Interface

func Code(c *tgframe.Container, code string)
func CodeWithConf(c *tgframe.Container, code string, conf *CodeConf)

Parameters

  • c: Parent container.
  • code: Code to display.
  • conf: Configuration for the code component.
// CodeConf provide extra config for Code Component.
type CodeConf struct {
	// Language is language of code block, leave empty to use `go`
	Language string

	// ID is id of the component
	ID string
}

Example

tgcomp.Code(c, "package main\n\nfunc main() {\n\tprintln(\"Hello, World!\")")
tgcomp.CodeWithConf(c, "package main\n\nfunc main() {\n\tprintln(\"Hello, World!\")",
    &tgcomp.CodeConf{
        Language: "go",
        ID:       "mycode",
    })