Gilbert Nwaiwu
Gilbert Nwaiwu

Reputation: 728

Using VueJS with a Go backend

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:

{{.Color}}

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

{{someVariable}} 

Both are for the same tag.

Upvotes: 7

Views: 5236

Answers (2)

Yurkol
Yurkol

Reputation: 1492

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

Upvotes: 2

gurghet
gurghet

Reputation: 7706

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

Upvotes: 14

Related Questions