将模板划分为文件错误

I’ve created a template which works as expected, now when the template is become bigger I want to Divide it to several files, what I did is the following for example

bigfile.txt :)

echo “I’m pre process”

echo “process”

echo “I’m post process”




t := template.Must(template.New("bigfile.txt").Parse(bigfile.txt))

Now this is working without any problem.

What I did now is divide the big file to 3 files

**base_pre.txt**

And here is the code inside

{{define "base_pre”}}

echo “I’m pre process”

{{end}}

base_pre.txt

And here is the code inside

{{define "base_post”}}

echo “I’m post process”

{{end}}

And in thebigfile.txtI’ve changed the

{{template "base_pre"}}

echo process

{{template "base_post”}}

When I run it I got error

ERROR template: bigfile.txt:1:11: executing “bigfile.txt" at <{{template "base_pre...>: template "base_pre" not defined