Sunday, 15 July 2012

go - parsing templates at compile time -



go - parsing templates at compile time -

in understanding, go templates parsed given source @ runtime in order compiled version of type template.template. then, compiled version executed on info actual templating.

but i'm wondering : possible parse template @ compile time ?

just create them global variables like this. you'll still parse templates @ run time binary fail run if can't parse them properly.

package main import ( "fmt" "text/template" ) var t = template.must(template.new("name").parse("text")) func main() { fmt.println("template", t) }

go

No comments:

Post a Comment