cryogen-project / cryogen-core

Cryogen's core
Eclipse Public License 1.0
69 stars 62 forks source link

Prevent klipse to emit empty html content #101

Closed sanel closed 7 years ago

sanel commented 7 years ago

When :klipse is set to {} (or not present at all) in config.edn, it will emit this code:

<link rel="stylesheet" type="text/css" href=nil>
<script>
window.klipse_settings = null;
</script>
<script src=nil></script> 

where browser will fail with GET request for given resource, which is nil. Here is a small patch to mitigate this (I've added it against blue_centered theme, but should be applicable to other themes as well):

--- a/resources/templates/themes/blue_centered/html/base.html
+++ b/resources/templates/themes/blue_centered/html/base.html
@@ -86,7 +86,9 @@
 <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
 {% script "js/highlight.pack.js" %}
 <script>hljs.initHighlightingOnLoad();</script>
+{% if klipse|not-empty %}
 {% if post.klipse %} {{post.klipse|safe}} {% endif %}
 {% if page.klipse %} {{page.klipse|safe}} {% endif %}
+{% endif %}
 </body>
 </html>
lacarmen commented 7 years ago

Thanks for the patch. I'll look at applying it to the rest of the themes when I get a chance.

madstap commented 7 years ago

I think it may be better to solve this further upstream, so you don't need to do this in every theme.