doushou3814 2016-04-13 02: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-13 04:58
    关注
    {{ printf "%#v" . }}
    

    Should print out the variable name and value.

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

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度