2016-08-03 13:16
浏览 496


I want to use Go templates as well as VueJS for data-binding. Has anyone integrated both before?

I wish to use VueJS primarily for Ajax calls as doing it manually(or with jQuery) always leaves my code messy.

To be more specific, if I have a simple<p> tag whose value is generated from a Go template like so:


Now I want to bind to the value in
like so:


Both are for the same tag.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanguoping2016 2016-08-03 14:43

    If you are mixing Vue.js with another templating system you can choose to change the interpolating delimiters (by default['{{','}}']) with something else.

    Vue.config.delimiters = ['${', '}']

    Now you can use {{.}} with golang and ${} with Vue

    点赞 打赏 评论
  • duan201444 2018-03-04 12:38

    At the Go's side you can define your own delimiters: https://golang.org/pkg/text/template/#Template.Delims

    点赞 打赏 评论

相关推荐 更多相似问题