0

I have a problem working with dot when I have template like this

{{=it.data[0].visitors}}

so this doesn't work

var data = [{
  visitors: 10
}];

var tempFn = doT.template("<h1>Here is a sample template {{=it.data[0].visitors}}</h1>");

var resultText = tempFn(data[0]);
A.B
  • 1

1 Answers1

0

You need to name what you insert as template vars :

http://jsfiddle.net/0ds9rfk1/

var tempFn = doT.template("<h1>Here is a sample template {{=it.data.visitors}}</h1>");
var resultText = tempFn({data:data[0]});

or

var tempFn = doT.template("<h1>Here is a sample template {{=it.data[0].visitors}}</h1>");
var resultText = tempFn({data});
Jayffe
  • 1,269
  • 9
  • 13