Skip to main content

Override blocks in included templates

Project description

This package adds the {% embed %} templatetag. This tag combines the functionality of the include tag and the extends tag to allow for more flexible and extensible modular template usage. Inspired by twig’s embed tag, this tag lets you override blocks that were defined in the included template.

Installation

Simply get the package from pip:

pip install django-embed-template

Then make sure to add django_embed_template to your INSTALLED_APPS in your settings.py.

Usage

Unlike the {% extends %} tag, the {% embed %} tag can be repeated in the template and does not have to occur as the first tag (essentially like the {% includes %} tag). Likewise, {% embed %} inherits the context by default, and allows you to pass additional context using the with keyword. Passing only the explicitly listed variables can be achieved using the only keyword.

TODO add an example

License

This package includes code that was directly derived from code from the Django project. The included django-LICENSE applies to those snippets. The included CC0 license applies to the rest of this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-embed-template-0.1.0.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

django_embed_template-0.1.0-py2.py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page