Skip to main content

A template tag to allow writing mixins instead of defining more files.

Project description

A template filter that allows you to define and use mixins.

Installation

In your Django project, run:

pip install django-template-mixins

and add mixin_templatetag to your INSTALLED_APPS setting:

INSTALLED_APPS = [
  ...,
  'mixin_templatetag'
]

and from there you can use it as follows:

{% load mixins %}

{% mixin foo %}
    <div>
        <div>{{ name }}</div>
        <div>{{ description }}</div>
    </div>
{% endmixin %}

{% block content %}
...
{% mix foo with name="hello" description="world" %}
...
{% endblock %}

Why django-template-mixins?

Currently in Django, if you want to repeat a block multiple times in separate blocks / areas in the same block, you have to create a separate file. The worst part is that these extracted bits of template tend to be single purpose - you aren’t likely to need it anywhere else besides that first template.

Mixins allow you to keep things in one place and allows you to avoid DRY.

Reporting bugs

You can report bugs in https://github.com/benlei/django-template-mixins/issues.

If you believe you’ve found a bug, please try to identify the root cause and write up some sample code on how to reproduce it.

Author

Benjamin Lei

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-template-mixins-0.2.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

django_template_mixins-0.2.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded 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