Commits

Mike Bayer committed 861dfad

tweaks

  • Participants
  • Parent commits 93104c3

Comments (0)

Files changed (2)

template_demo/static/css/style.css

 #nav li a {
   float: left;
   padding: 5px 12px;
+  width:100%;
   font-weight: normal;
   text-decoration: none;
   color: #000;

template_demo/static/js/app.js

 var app = function(window, $, hb) { 
-    var history = window.History;
     var _template_cache = {};
-    
+
+    /**
+     * get_template
+     *
+     * Retrieve a handlebars template from the
+     * _template_cache collection.  If not present, 
+     * retrieve it from the server's
+     * static/templates directory, compile it, and store the
+     * compiled form in the _template_cache collection,
+     * returning the compiled form.  
+     */
     function get_template(tname) {
         if (_template_cache[tname] == undefined) {
             $.ajax(static_url + "templates/" + tname, {
         return _template_cache[tname];
     }
 
+    /**
+     * render
+     *
+     * Render a handlebars template given the 
+     * template name, data for render, and DOM
+     * target.
+     *
+     * The is_page flag indicates the source of the
+     * render for demonstration purposes.
+     * 
+     */
     function render(data, tname, target, is_page) {
         if (target == undefined) {
             target = "#content";
         $(target).html(html);
     }
     
-    function render_via_api(href, api, tname) {
+    /**
+     * render_via_api
+     *
+     * Respond to a link which contains api href and
+     * template name.  Call the server's api href via 
+     * AJAX, assigning as a callback a call to the 
+     * render() function which will render the given template
+     * client-side.
+     */
+    function render_via_api(api, tname) {
         $.ajax(api,{
             success:function(data, textStatus, jqXHR) {
                 render(data, tname, undefined, false);
         })
     }
 
-    function render_api_server() {
-        
-    }
 
     $(document).ready(function() {
         $("body a[api]").unbind('click').click(function() {
             var a = $(this);
-            render_via_api(a.attr('href'), a.attr('api'), a.attr('template'));
+            render_via_api(a.attr('api'), a.attr('template'));
             return false;
         });
     });
     
+    /* the public api of the app object. */
     return {
-        render : render,
-        render_api_server: render_api_server
+        render : render
     }
 }(window, jQuery, Handlebars);