doushou3814 2016-04-12 18:55 采纳率: 100%
浏览 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-12 20:58
    关注
    {{ printf "%#v" . }}
    

    Should print out the variable name and value.

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部