jQuery Template Default

by HYEONGJINKIM

HTML

<script src='http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js'></script>

<body>
    <h3>Person Details</h3>
    <div class='personal-detais'>
    </div>
</body>

<script type='text/x-jquery-tmpl' id='person-template'>
  <div class='person'>
    <strong>Name: </strong> ${ Name } <br/>
    <strong>Age: </strong> ${ Age } <br/>
    <strong>Country: </strong> ${ Country } <br/>
  </div>
</script>

JavaScript

var steve  = {'Name': 'Steve Robinson', 'Age':22, 'Country':'India'};

$(document).ready(function(){
    // $.tmpl(template,[data],[options]);
    $.tmpl( $('#person-template'), steve).appendTo('.personal-detais');
    //$('#person-template').tmpl(steve).appendTo('.personal-detais');
});