attachObject / template engine

The layout cell.attachHTMLString(x) has become very useful in my application where I need to show static information in a cell, such as customer name and address.

Does dhtmlx have a template engine? I want to define a template:

<div id='xyz' style='display:none'>
  <b>Name: </b> #name#
</div>

And then have way of binding data into the template like:

  var x = template.bind('xyz', {name:'abc'})
  cell.attachHTMLString(x)

I suppose I could write something or find such a function, just wanted to check with the masters of code first.

Hi

not excactly like in your post, but:

// add once on your page function parseTemplate(tpl, data) { return tpl.replace(/#([a-zA-Z0-9_-]{1,})#/g, function(t,k){ if (k.length > 0 && typeof(data[k]) != "undefined") { return String(data[k]); } return ""; }); };

// and make some tests console.log( parseTemplate( "<div id='xyz' style='display:none'><b>Name: </b> #name#</div>", {name:'abc'} ) );

Thank you for your help. I started messing around with doT.js olado.github.io/doT/ it works well with dhtmlx.