Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Vue.js in Golang's HTML templates [duplicate]

Tags:

html

go

vue.js

I want to use Vue.js with the Golang's HTML template engine but as both use {{ ... }} for syntax, they conflict with each other...

Does anyone has already did it somehow or have any suggestions on how to overlap this problem?

Thanks in advance.

like image 452
João Cerqueira Avatar asked Aug 04 '16 10:08

João Cerqueira


People also ask

Can you use Vue in HTML?

You can use Vue to build standard Web Components that can be embedded in any HTML page, regardless of how they are rendered.

How do you link Vue js file to HTML?

The simplest way to get started with Vue is to grab the development version script for it and add it to the head tag of your HTML file. Then you can start Vue code inside the HTML file inside of script tags. And have the Vue code connect up with an existing element on your HTML page.

What is interpolation in Vue JS?

Vue Interpolation It's simply the process of displaying a string that's defined within your component logic.

What is inline template in Vue?

In 2. x, Vue provided the inline-template attribute on child components to use its inner content as its template instead of treating it as distributed content. <my-component inline-template> <div> <p>These are compiled as the component's own template.</


2 Answers

You can change delimiters used by Vue. Look the documentation

like image 101
David Avatar answered Oct 05 '22 20:10

David


You can change the default delimiters for Go templates. Use:

func (t *Template) Delims(left, right string) *Template

Docs: https://golang.org/pkg/text/template/#Template.Delims

like image 22
abhink Avatar answered Oct 05 '22 19:10

abhink