@register.tag<EOL>def include_if_exists(parser, token):
try:<EOL><INDENT>tag_name, template_name = token.split_contents()<EOL><DEDENT>except ValueError:<EOL><INDENT>raise template.TemplateSyntaxError("<STR_LIT>" % token.contents.split()[<NUM_LIT:0>])<EOL><DEDENT>return IncludeNode(template_name)<EOL>
Usage: {% include_if_exists "head.html" %}

    This will fail silently if the template doesn't exist. If it does, it will
    be rendered with the current context.

    From: https://djangosnippets.org/snippets/2058/