Go Mustache

1 개요[ | ]

Go Mustache

2 예시1: hello world[ | ]

Go
Copy
package main

import "fmt"
import "github.com/cbroglie/mustache"

func main() {
	data, _ := mustache.Render("hello {{c}}", map[string]string{"c": "world"})
	fmt.Println(data)
}
Loading
Go
Copy
package main

import "fmt"
import "github.com/cbroglie/mustache"

func main() {
	data, _ := mustache.Render("hello {{c}} {{x}}", map[string]string{"c": "world"})
	fmt.Println(data)
}
Loading
Go
Copy
package main

import "fmt"
import "github.com/cbroglie/mustache"

func main() {
	data, _ := mustache.Render("hello {{c}} {|{x}|}", map[string]string{"c": "world"})
	fmt.Println(data)
}
Loading

3 예시2: 파일[ | ]

Go
Reload
layout.html.mustache
Copy
<html>
<head><title>Hi</title></head>
<body>
{{{content}}}
</body>
</html>
Loading
template.html.mustache
Copy
<h1> Hello World! </h1>
Loading
main.go
Copy
package main

import "fmt"
import "github.com/cbroglie/mustache"

func main() {
	data, _ := mustache.RenderFileInLayout("template.html.mustache", "layout.html.mustache", nil)
	fmt.Println(data)
}
Loading

4 같이 보기[ | ]

5 참고[ | ]