[#6556] start fixing undefined vars in templates
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index a3e8d6b..999b53b 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -28,7 +28,7 @@
   {% endif %}
 {%- endmacro %}
 
-{% macro gravatar(user, size, className) -%}
+{% macro gravatar(user, size, className=None) -%}
   {% set display_name = h.really_unicode(user.display_name) %}
   {% if user.icon_url() %}
     <img src="{{user.icon_url()}}"
diff --git a/Allura/allura/templates/jinja_master/master.html b/Allura/allura/templates/jinja_master/master.html
index e3afa6a..2501cc6 100644
--- a/Allura/allura/templates/jinja_master/master.html
+++ b/Allura/allura/templates/jinja_master/master.html
@@ -57,7 +57,7 @@
       <style type="text/css">
         {{c.project.neighborhood.get_custom_css()|safe}}
       </style>
-    {% elif neighborhood and neighborhood.css %}
+    {% elif neighborhood|default and neighborhood.css %}
       <style type="text/css">
         {{neighborhood.get_custom_css()}}
       </style>
@@ -76,7 +76,7 @@
     {% endfor %}
     {{theme_macros.header(g.login_url, '/auth/logout')}}
     {% set flash = tg.flash_obj.render('flash', use_js=False) %}
-    <section id="page-body" class="{{g.document_class(neighborhood)}}">
+    <section id="page-body" class="{{g.document_class(neighborhood|default)}}">
 	  <div id="nav_menu_holder">
             {% block nav_menu %}
             {% include g.theme.nav_menu %}
@@ -88,7 +88,7 @@
         {% endblock %}
       </div>
       <div id="content_base">
-			  {% if not hide_left_bar %}
+			  {% if not hide_left_bar|default %}
 			    {% block sidebar_menu %}
           {% include g.theme.sidebar_menu %}
           {% endblock %}
@@ -96,7 +96,7 @@
 			  {% else %}
           {% set outer_width = 24 %}
         {% endif %}
-			  {% if show_right_bar %}
+			  {% if show_right_bar|default %}
           {% set inner_width = outer_width - 8 %}
 			  {% else %}
           {% set inner_width = outer_width %}
@@ -110,11 +110,11 @@
             <!-- /actions -->
           </h2>
 		{% block edit_box %}{% endblock %}
-          <div{% if show_right_bar %} class="{% block inner_grid %}grid-{{inner_width}}"{% endblock %}{% endif %}>
+          <div{% if show_right_bar|default %} class="{% block inner_grid %}grid-{{inner_width}}"{% endblock %}{% endif %}>
             {% block before_content %}{% endblock %}
             {% block content %}{% endblock %}
           </div>
-			{% if show_right_bar %}
+			{% if show_right_bar|default %}
           <div id="sidebar-right" class="grid-6 fright">
             {% block right_content %}{% endblock %}
           </div>
@@ -139,7 +139,7 @@
       {{ blob }}
     {% endfor %}
     {% block extra_js %}{% endblock %}
-    {% if neighborhood %}
+    {% if neighborhood|default %}
       {{ neighborhood.site_specific_html | safe }}
     {% elif c.project.neighborhood %}
       {{ c.project.neighborhood.site_specific_html | safe }}
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 4280881..06880a5 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -47,7 +47,7 @@
             {% if loop.last and admins|length > 5 -%}
                 and <a href="{{ c.project.url() }}_members/">{{ admins|length - 4 }} others</a>
             {% else %}
-                <a href="{{ admin.url() }}">{{ admin.username }}</a>{{ ',' if not loop.last }}
+                <a href="{{ admin.url() }}">{{ admin.username }}</a>{{ ',' if not loop.last else '' }}
             {% endif %}
         {%- endfor -%}
     </div>
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index f8b9c8e..98b38e4 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -19,7 +19,7 @@
 {% set ul_active = [] %}
 {% macro sidebar_item(s) -%}
   {% if s.url %}
-    {% if not ul_active[-1] %}
+    {% if not ul_active or not ul_active[-1] %}
       <ul class="sidebarmenu">
       {% do ul_active.append(True) %}
     {% endif %}
@@ -45,7 +45,7 @@
   {% else %}
     <div>&nbsp;</div>
   {% endif %}
-    {% if c.custom_sidebar_menu %}
+    {% if c.custom_sidebar_menu|default %}
       {% for s in c.custom_sidebar_menu %}
         {{sidebar_item(s)}}
       {% endfor %}