Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div class="game-container"></div>
  2. <script src="js/jquery-2.1.0.min.js"></script>
  3. <script src="js/underscore.js"></script>
  4.  
  5. <script type="text/template" id="template">
  6.     <h2>
  7.         <%- rc.name %>
  8.     </h2>
  9. </script>
  10.  
  11.  
  12. <script type="text/javascript">
  13.     // Grab the HTML out of our template tag and pre-compile it.
  14.     var template = _.template(
  15.             $( "#template" ).html()
  16.     );
  17.  
  18.     // Define our render data (to be put into the "rc" variable).
  19.     var templateData = {
  20.     rc : {
  21.         name: "Alex"
  22.     }
  23.     };
  24.  
  25.     // Render the underscore template and inject it after the H1
  26.     // in our current DOM.
  27.     $( ".game-container" ).after(
  28.             template( templateData )
  29.     );
  30.  
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement