semvec/pypi-packages huggingface dataset:
django-components-preprocessor 0.3.0
A preprocessor for Django templates that replaces custom HTML tags with component tags.

# django-components-preprocessor

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

## Description

This project allows you to use regular HTML tags for your django-component components.

### Before

```
{% component_block "calendar" attr="value" %}
  {% fill "header" %}
    Custom header
  {% endfill %}
{% encomponent_block %}
```

### After

```
<calendar attr="value">
  <calendar.header>
    Custom header
  </calendar.header>
</calendar>
```

## Installation

- Install the package using pip:

```bash
pip install django-components-preprocessor
```

- Import the `with_components_preprocessor` function and use it to wrap the `loaders` option in your `TEMPLATES` setting:

```python
# settings.py
from django_components_preprocessor import with_components_preprocessor
...

# Example TEMPLATES setting
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "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",
            ],
            "loaders": with_components_preprocessor(
                "django.template.loaders.filesystem.Loader",
                "django.template.loaders.app_directories.Loader",
                "django_components.template_loader.Loader",
            ),
            "builtins": [
                "django_components.templatetags.component_tags",
            ],
        },
    },
]
```

## How it works

Your templates will be preprocessed before being passed to the regular django template engine.
The preprocessor will replace custom tags (i.e. `<calendar />`) with the regular django-component tags
(i.e. `{% component "calendar" }`).
Additionally, custom tags with dots (i.e. `<calendar.header />`) will be replaced with the regular django-component tags
(i.e. `{% fill "header" %}`), where the slot name is the last part of the tag name split at the dot.
The tags are matched by name and are case-sensitive.

Currently, custom tags are found using regular expressions, which is obviously a bit whacky.
It does however work for most cases, and is a lot more readable than the regular django-component tags.
A more robust solution would be to use a proper HTML parser, but that's a bit overkill at this point in time.

If, due to the limitations of the regular expressions, you find that the preprocessor doesn't work for your use case,
you can always use the regular django-component tags as you normally would.

## License

This project is licensed under the [MIT License](LICENSE).
tableplus-db-urls 0.1.4
Generate TablePlus DB URLs from CookieCutter Django to make setting up connections easier.
Requires Python: >=3.8

# TablePlus DB URLS

![Coverage](https://img.shields.io/badge/coverage-98%25-brightgreen)

## Overview

Generate TablePlus DB URLs from CookieCutter Django to make setting up connections easier. Yea, I'm that lazy!

It assumes you are using [django-cookiecutter](https://github.com/cookiecutter/cookiecutter-django) with the `use_docker=y` option and that you are connecting to your Postgres DB over SSH using your private key (`~/.ssh/config`) in production.

It is looking for your `.postgres` env files that are generated by cookiecutter at

## Installation

```bash
$ python3 -m pip install tableplus-db-urls
```

## Usage

```bash
# --path should be your django project root
$ tableplus generate --path="." --name="DB Name" --ssh-user="user" --ssh-host="xxx.xxx.x.x"
```

> **NOTE:** TablePlus DB URLs assumes you use an SSH Key to login and not password.

Then in TablePlus, on the main screen, right-click and choose `New` > `Connection from URL...` and use the URLs provided by the output.

## Development

```bash
make env
make pip_install
make pip_install_editable
```

## Testing

```bash
make pytest
make coverage
make open_coverage
```

## Issues

If you experience any issues, please create an [issue](https://github.com/tsantor/tableplus-db-urls/issues) on GitHub.

# History

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## 0.1.4 (2024-05-15)

- Too quick on the trigger! Bug fix with CLI implementation after `name` added.

## 0.1.3 (2024-05-15)

- Bug fix with CLI implementation after `name` added.

## 0.1.2 (2024-05-15)

- Added `name` argument to name the connection.

## 0.1.1 (2024-04-23)

- Moved from `argparse` to `click`
- Moved from `python-environ` to `python-dotenv`
- Fixed bug with production URL

## 0.1.0 (2024-04-09)

- First release