Handlebars is a JavaScript page template library that helps you easily build semantic templates.
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>handlebars</title>
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >
<meta http-equiv= "description" content= "This are my page" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<script src= "${base}/js/jquery1.11.min.js" ></script>
<script src= "${base}/js/handlebars-v3.0.0.js" ></script>
<body>
<div id=tt style= ' Display:none ' >
<div class= "Entry" >
<div class= "Body" >{{body}}</div>
</div>
</div>
</body>
<script type= "Text/javascript" >
$ (' #tt '). Before (' <script id= "temp" type= "sfd" > ");
$ (' #tt '). After ("</script>");
var Source = $ ("#tt"). html ();
alert (source);
var template = handlebars.compile (source);
var data = {title: ' My New Post ', body: ' This is my post! '
};
var result = template (data);//fill in the template
Console.log (result);
$ (' #tt '). before (result);
</script>
The example is very simple, specific details can refer to thinkvitamin article Getting started with handlebars.js, I hope you can enjoy.