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
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.
"""
The {% embed %} tag can be used in two ways.
- To set which template will be used to render a particular model::
+ First, to set which template will be used to render a particular model. This declaration can be placed in a base template and will propagate into all templates that extend that template.
+
+ Syntax::
{% embed <app_label>.<model_name> with <template> %}
{% embed <app_label>.<model_name> with <template> %}
- To embed the instance specified by the given parameters in the document with the previously-specified template (any kwargs provided will be passed into the context of the template)::
+ Second, to embed a specific model instance in the document with a template specified earlier in the template or in a parent template using the first syntax. The instance can be specified as a content type and pk or as a context variable. Any kwargs provided will be passed into the context of the template.