I've template with 1 file (original file)which works as expected, now when it comes bigger I've started to divide it to 3 files
and just copy and paste the data from the original file to 3 files and I was able to see that the template was executed successfully but the data is missing in the start
and the end
template ,just the main
template receive the data properly from structData
for example
startTemple.txt
{{define "start"}}
...
{{end}}
main.txt (here i include both template)
{{template "start"}}
...
{{template "end"}}
endTemplate.txt
{{define "end"}}
...
{{end}}
I use the following
t, err := template.New(mainTemplateName).Funcs(funcMap).ParseFiles(startPath, mainPath, endPath)
err = t.Execute(templFile, structData)
if err != nil {
logs.Logger.Error(err)
}
I use the exact code as before and the issue is that the data from structData
is not appear in start
and end
template after generation, just in the main
is getting the structData properly, what could I be missing here ?
the templates (start main end) was generated successfully with the hardcoded data, but the data which should come from structData
, is not add during the generation to the start
and end
templates
Should I add the structData
also to the start
and end
somehow ?