From 951fffb3eb2e1cce80c923936b4157399ca42e49 Mon Sep 17 00:00:00 2001 From: Matthew Scragg Date: Wed, 10 Sep 2014 11:09:29 -0500 Subject: [PATCH] make sure partial has data before register --- realms/static/js/main.js | 2 +- realms/templates/wiki/edit.html | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/realms/static/js/main.js b/realms/static/js/main.js index 180d438..278785d 100644 --- a/realms/static/js/main.js +++ b/realms/static/js/main.js @@ -75,7 +75,7 @@ var MDR = { if (sanitize) { // Causes some problems with inline styles html = html_sanitize(html, function(url) { - if(/^https?:\/\//.test(url)) { + if(/^(\/|https?:\/\/)/.test(url)) { return url } }, function(id){ diff --git a/realms/templates/wiki/edit.html b/realms/templates/wiki/edit.html index d839710..0559e2b 100644 --- a/realms/templates/wiki/edit.html +++ b/realms/templates/wiki/edit.html @@ -4,7 +4,13 @@ $(function(){ {% if partials %} {% for name, value in partials.items() %} - Handlebars.registerPartial({{ name|tojson|safe }}, {{ value.data|tojson|safe }}); + {% if name and value %} + try { + Handlebars.registerPartial({{ name|tojson|safe }}, {{ value.data|tojson|safe }}); + } catch(e) { + // no data? + } + {% endif %} {% endfor %} {% endif %} $("#start-togetherjs").click(function(){