Commit cd652918 authored by Kroustouris Stauros's avatar Kroustouris Stauros
Browse files

include maybe

parent dcfcddae
<iframe id='logos' scrolling="no" marginheight="0" marginwidth="0" src="" frameborder="0" height="60" width="500" align="middle"></iframe>
<style type="text/css" scoped>
iframe#logos {
width: 100%;
height: 60px;
@media screen and (max-width: 480px) {
iframe#logos {
height: 120px;
......@@ -16,7 +16,7 @@
Powered by <a href="" target="_blank">DjNRO</a> v{{VERSION}}
{% if "partial/bottom_iframe.html"|template_exists %}
<div class="">
{% include 'partial/bottom_iframe.html' %}
{% include_maybe 'partial/bottom_iframe.html' %}
{% endif %}
from django import template
from django.template.defaultfilters import stringfilter
from django.template.loader_tags import do_include
from django.template.defaulttags import CommentNode
register = template.Library()
......@@ -13,3 +15,29 @@ def template_exists(value):
return True
except template.TemplateDoesNotExist:
return False
def do_include_maybe(parser, token):
bits = token.split_contents()
if len(bits) < 2:
raise template.TemplateSyntaxError(
"%r tag takes at least one argument: "
"the name of the template to be included." % bits[0])
silent_node = do_include(parser, token)
except template.TemplateDoesNotExist:
# Django < 1.7
return CommentNode()
_orig_render = silent_node.render
def wrapped_render(*args, **kwargs):
return _orig_render(*args, **kwargs)
except template.TemplateDoesNotExist:
return CommentNode()
silent_node.render = wrapped_render
return silent_node
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment