Placeholders are not replaced

后端 未结 2 1167
小鲜肉
小鲜肉 2021-01-28 14:32

I am experimenting with the package http/template.
I have also already managed that e.g. the header, footer, navbar and so on were included in the base templ

相关标签:
2条回答
  • 2021-01-28 14:57

    You have to pass the context to the instantiated templates. Use

    {{ template "content" .}}
    

    to pass the data in . to the content template.

    0 讨论(0)
  • 2021-01-28 15:02

    You're not passing any data to the child templates. Per the docs:

    {{template "name"}}
        The template with the specified name is executed with nil data.
    
    {{template "name" pipeline}}
        The template with the specified name is executed with dot set
        to the value of the pipeline.
    
    0 讨论(0)
提交回复
热议问题