doushou3814 2016-04-13 02:55 采纳率: 0%
浏览 79
已采纳

Golang模板:上下文是什么?

I want to see what is in the context that is passed into the template. What I do is basically putting the dot right there in the HTML.:

{{$.}}

What I get back when the HTML is rendered is:

{http://localhost:1315/blog/index.xml 0xc08fdf36g0 map[Pages:[]] Blog [] map[] 2016-04-07 15:34:03 -0700 PDT 2016-04-07 15:34:03 -0700 PDT { 0} {/blog/ http://localhost:1315/blog/ } false 0xc0825878d0 {{0 0} 1} <nil>}

I know for example there is .Site inside . but it doesn't even show up in the rendered HTML. How can I get the context in a more understandable form so I can see what it is without previously knowing all the attributes it is supposed to have?

  • 写回答

1条回答 默认 最新

  • dongqiaozhe5070 2016-04-13 04:58
    关注
    {{ printf "%#v" . }}
    

    Should print out the variable name and value.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?