template func takes an extra argument to send data,

{{ template "inner" .}}{{end}}


I can t find a link to doc for that matter :s

nothing here
https://golang.org/pkg/text/template/#hdr-Nested_template_definitions

or here 
https://golang.org/pkg/text/template/#hdr-Functions

The only related example is in
https://golang.org/pkg/text/template/#hdr-Actions

{{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.


Maybe the 2nd desc is not so obvious for new comers.
Maybe it is a bit lost in the middle of everything else.
not sure.

On Monday, March 13, 2017 at 12:28:21 PM UTC+1, Uvelichitel wrote:
>
> How to pass value in nested template if possible? 
> Template package has terse documentation and not much examples. 
> In brief I want to 
>      if err := template.Must(template.New("").Parse(`{{ define "inner" 
> }}{{ . }}{{end}}{{ define "outer" }}{{ template 
> "inner"}}{{end}}`)).ExecuteTemplate(os.Stdout, "outer", "foo"); err != nil 
> { 
>          print(err) 
>      } 
> which write 
>      <no value> 
> instead of desired "foo". Error isn't spawned. Am I missing something? 
> Cheers. 
> __ 
> Ilya 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to