forked from tyler-sommer/stick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_fs_test.go
More file actions
41 lines (37 loc) · 846 Bytes
/
example_fs_test.go
File metadata and controls
41 lines (37 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package stick_test
import (
"fmt"
"os"
"path/filepath"
"github.com/tyler-sommer/stick"
)
// An example showing the use of the provided FilesystemLoader.
//
// This example makes use of templates in the testdata folder. In
// particular, this example shows vertical (via extends) and horizontal
// reuse (via use).
func ExampleEnv_Execute_filesystemLoader() {
d, _ := os.Getwd()
env := stick.NewEnv(stick.NewFilesystemLoader(filepath.Join(d, "testdata")))
params := map[string]stick.Value{"name": "World"}
err := env.Execute("main.txt.twig", os.Stdout, params)
if err != nil {
fmt.Println(err)
}
// Output:
// This is a document.
//
// Hello
//
// An introduction to the topic.
//
// The body of this topic.
//
// Another section
//
// Some extra information.
//
// Still nobody knows.
//
// Some kind of footer.
}