Testing Mustache.js Template

by benhowdle89

HTML

<script src="https://github.com/janl/mustache.js/raw/master/mustache.js"></script>
<script id="loginTpl" type="text/template"><form id="login" class="group row">
	<div class="group">
		<input type="text" id="username" name="username" placeholder="Your username" autocorrect="off" autocomplete="off"></input>
		<button id="login-btn" class="button" type="submit">Login</button>
	</div>
</form></script>

CSS

div {
    font:14px Arial;
    margin:50px 20px;
}

JavaScript

var fragment = document.createElement('div');
var template = document.getElementById('loginTpl').innerHTML;
var html = Mustache.to_html(template);

fragment.innerHTML = html;
document.body.appendChild(fragment);