37 lines
806 B
Go
37 lines
806 B
Go
package rendering
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
)
|
|
|
|
type BlockOptions struct {
|
|
FullText string `json:"full_text"`
|
|
Align string `json:"align"`
|
|
Name string `json:"name"`
|
|
Urgent bool `json:"urgent"`
|
|
Separator bool `json:"separator"`
|
|
SeparatorBlockWidth int `json:"separator_block_width"`
|
|
}
|
|
|
|
func NewBlockOptions() BlockOptions {
|
|
return BlockOptions{
|
|
Align: "left",
|
|
Urgent: false,
|
|
Separator: false,
|
|
SeparatorBlockWidth: 0,
|
|
}
|
|
}
|
|
|
|
func Block(name string, options BlockOptions) string {
|
|
options.Name = name
|
|
|
|
json, _ := json.Marshal(options)
|
|
block := string(json)
|
|
|
|
block = strings.ReplaceAll(block, `\u003c`, "<")
|
|
block = strings.ReplaceAll(block, `\u003e`, ">")
|
|
|
|
return block
|
|
}
|