A
A
AdNahim2016-08-02 17:23:38
JavaScript
AdNahim, 2016-08-02 17:23:38

How to make mustache friends in node.js and vue.js?

I decided to try vue.js and immediately ran into problems.
As I understand it, the fact is that the application is based on node.js and mustache is used , which apparently "conflicts" with mustache when outputting data from vue.js.
In general, simple:

var App = Vue.extend({
  name: "app"
});

var vm = new App({
  el: "#app",
  data: {
    name: 'test'
  },
  ready: function(){
    console.log("Готово...");
  }
});

html:
<div id="app" data-name="{{name}}">{{name}}</div>
when working through node.js , it does not display anything in #app , but if you just open it in the browser, bypassing node.js, then everything will work fine.
It is clear that the matter is in mustache, or rather, apparently, during rendering, {{constructions}} , which are not specified in res.render , are thrown back, from here they do not reach vue.js. How to solve this, except how to abandon mustash on the backend?
Thanks to!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AdNahim, 2016-08-04
@alexanderkx

The solution was found.
To make it clear to mustache that {{construct}} should not be processed on the server side, you need to highlight the required markup section with the construction: {{={{{ }}}=}} ... {{{={{ }}=}}}.
So in my case it looks like this:

{{={{{ }}}=}}
   <div id="app" data-name="{{name}}">{{name}}</div>
{{{={{ }}=}}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question