Last active
December 18, 2015 20:39
-
-
Save abachuk/5841432 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Main script file --> | |
<!-- when JSON object is received it's passed to template (id of script tag) --> | |
<!-- posts in the end is JSON object we received from AJAX --> | |
var template = _.template( $("#posts_template").html(), posts ); | |
<!-- in HTML document --> | |
<!-- emplty placeholder --> | |
<div id="posts-container"></div> | |
<!-- compiled template adds html to empty placeholder --> | |
<script type="text/template" id="posts_template"> | |
<ul> | |
<% _.each(posts, function(post){ %> | |
<li><%= post.title %></li> | |
<% }); %> | |
</ul> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment