X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/ed6b9876b7abff0b2dc6266d6f769c319f358a9c..61b73fe068172f02d6c47e2b5387161919ec9618:/philo/templatetags/embed.py diff --git a/philo/templatetags/embed.py b/philo/templatetags/embed.py index eb4cd68..b024b1b 100644 --- a/philo/templatetags/embed.py +++ b/philo/templatetags/embed.py @@ -1,8 +1,13 @@ +""" +The embed template tags are automatically included as builtins if :mod:`philo` is an installed app. + +""" from django import template -from django.contrib.contenttypes.models import ContentType from django.conf import settings +from django.contrib.contenttypes.models import ContentType from django.template.loader_tags import ExtendsNode, BlockContext, BLOCK_CONTEXT_KEY, TextNode, BlockNode -from philo.utils import LOADED_TEMPLATE_ATTR + +from philo.utils.templates import LOADED_TEMPLATE_ATTR register = template.Library() @@ -280,17 +285,29 @@ def parse_content_type(bit, tagname): except ValueError: raise template.TemplateSyntaxError('"%s" template tag expects the first argument to be of the form app_label.model' % tagname) try: - ct = ContentType.objects.get(app_label=app_label, model=model) + ct = ContentType.objects.get_by_natural_key(app_label, model) except ContentType.DoesNotExist: raise template.TemplateSyntaxError('"%s" template tag requires an argument of the form app_label.model which refers to an installed content type (see django.contrib.contenttypes)' % tagname) return ct -def do_embed(parser, token): +@register.tag +def embed(parser, token): """ - The {% embed %} tag can be used in two ways: - {% embed . with