Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue.js change {{ }} tags

Tags:

vue.js

I want to change the {{ something }} by <% something %> in Vue.js, how could I achieve that, is it even possible?

An equivalent for what I look for in AngularJS:

var app = angular.module('app', [], function($interpolateProvider) {     $interpolateProvider.startSymbol('<%');     $interpolateProvider.endSymbol('%>'); }); 
like image 208
Hammerbot Avatar asked Nov 10 '15 11:11

Hammerbot


2 Answers

With the latest version (2.0.5), the above doesn't work. Rather than assigning to the global config, you pass the delimiters as an option to the Vue instance:

new Vue({     el: '#app',     data: data,     delimiters: ["<%","%>"] }); 

At least, that's what I had to do to make it work.

like image 154
jaynabonne Avatar answered Oct 21 '22 19:10

jaynabonne


You should modify the delimiters property of configuration object.

Vue.config.delimiters = ['<%', '%>'] 

Edit: This solution works for Vue 1.x and lower. See @Skip and @jaynabonne responses for Vue 2.x solution

like image 43
Pantelis Peslis Avatar answered Oct 21 '22 19:10

Pantelis Peslis