A small package to easily create components inside your templates without saving them in the templates folder.
Project description
Django Simple Components
Django Simple Components is a small package to easily create components inside your templates without saving them in the templates folder.
Quick start
1. Install package:
To get started, install the package from pypi:
pip install django-simple-components
Now you can add simple_components
to your django project. Change your INSTALLED_APPS
setting like this:
INSTALLED_APPS = [
...,
"simple_components",
]
Optionally, you can specify simple_components
as builtins and this will be available in any of your templates without additionally specifying {% load simple_components %}
:
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
"builtins": ["simple_components.templatetags.simple_components"],
},
},
]
If you choose not use it as a built-in, you will need to add {% load simple_components %}
to the top of your template whenever you want to use simple components.
2. Create component inside your template:
{% load simple_components %}
{% set_component "first_component" %}
<div class="card">
<h3>{{ title }}</h3>
<p>{{ description }}</p>
</div>
{% end_set_component %}
<div class="card-list">
{% component "first_component" title="Hello world!" description="Some text..." %}
{% component "first_component"
title="Some lines"
description="Other text..."
%}
{% with value="this text will be capitalized later" %}
{% component "first_component" title=123 description=value|capfirst %}
{% endwith %}
</div>
3. Hooray! Everything is ready to use it.
Contributing
If you would like to suggest a new feature, you can create an issue on the GitHub repository for this project. Also you can fork the repository and submit a pull request with your changes.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
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
Built Distribution
Hashes for django-simple-components-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bfb7171a05118d0aa01662f24767132120ecbb47c39d6c57c88347c424a3c4f |
|
MD5 | c363c74e368f0938afe68f2f1d30b6ac |
|
BLAKE2b-256 | a7aba5b904778c7d4eccb50aca723c356e011f833638272112ec347704d621a9 |
Hashes for django_simple_components-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b45d63ed15ed2616f1cdbdaf60ccd7c52b79c1bae90922054a6a691fe4e713f1 |
|
MD5 | 34960c8d9fe8749c90345dc9b169d51f |
|
BLAKE2b-256 | e8f18b88b74ab0b39f4355bb2f02e181fa1833060ddf986e4df713c8b33a699c |