simple demo of Handlebars.js & jquery.js

<html>
	<head>
		<script src="jquery-1.11.0.min.js"></script>
		<script src="handlebars-v1.3.0.js"></script>
	</head>
	<script>
		$(document).ready(function() {
			var source   = $("#entry-template").html();
			var template = Handlebars.compile(source);
			var context = {title: "My New Post", body: "This is my first post!"}
			var html = template(context);
			$("body").html(html);
		})
	</script>
	<body>
	
	</body>
	<script >
	  <div class="entry">
		  <h1>{{title}}</h1>
		  <div class="body">
			{{body}}
		  </div>
		</div>
	</script>
</html>

  

相关文章:

  • 2021-10-05
  • 2022-03-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-05-24
猜你喜欢
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-10-12
相关资源
相似解决方案