JSFiddle - React, Tailwind, and code Playground

by ozzon91

HTML

<ul id="comment-list">
  
</ul>


<script type="text/template" id="t-item-comment">
<% _.each(data, function(el,n) { %>
<li>
<b><%- el.name %></b>
<p><%- el.text %></p>
</li>
<% }); %>
</script>

JavaScript

var comments = [
	{name: 'Vasy', text: 'hello mens'},
  {name: 'Vasy', text: 'hello mens'},
  {name: 'Vasy', text: 'hello mens'}
];

renderList(comments);

function renderList(data) {
	var compile = _.template(getTpl('t-item-comment'));
  getId('comment-list').innerHTML = compile({data: data});
}

function getTpl(tplId) {
	return getId(tplId).innerHTML;
}

function getId(id) {
	return document.getElementById(id);
}