Bilit (pronounced /ˈbilit/) is a bidirectional template library for Go. Inspired by Javascript's Template Literals and Nunjucks
Powered by Regular Expressions
template := bilit.Template("Hello, I'm {{name}} from ${City}, {{from_state}}")
dataSrc := map[string]string{
"name": "John",
"City": "Dallas",
"from_state": "TX",
}
str := template.Populate(dataSrc)
fmt.Println(str, "end")
// "Hello, I'm John from Dallas, TX"
data := template.Pull(tr)
fmt.Println(data)
// map[City:Dallas from_state:TX name:John]
const template = "Hello, I'm {{name}} from ${City}, {{from_state}}"
dataSrc := map[string]string{
"name": "John",
"City": "Dallas",
"from_state": "TX",
}
str := bilit.Populate(template, dataSrc)
fmt.Println(str, "end")
// "Hello, I'm John from Dallas, TX"
data := bilit.Pull(template, str)
fmt.Println(data)
// map[City:Dallas from_state:TX name:John]