template-nest-go/test_nest.go

43 lines
962 B
Go

package main
import (
"fmt"
"tntester/template_nest"
)
func main(){
templates := map[string]string{
"00-simple-page": `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Simple Page</title>
</head>
<body>
<p>A fairly simple page to test the performance of Template::Nest.</p>
<p><!--% variable %--></p>
<!--% simple_component %-->
</body>
</html>`, "00-simple-component": `<p><!--% variable %--></p>`}
json := []byte(`{
"TEMPLATE": "00-simple-page",
"variable": "Simple Variable",
"simple_component": {
"TEMPLATE":"01-simple-component",
"variable": "Simple Variable in Simple Component"
}
}`)
nest := template_nest.New( templates )
html := nest.Render( json )
fmt.Println( html )
}