ssi-views


Namessi-views JSON
Version 0.6.0 PyPI version JSON
download
home_pageNone
SummaryA simple Django application to process SSI includes.
upload_time2024-12-20 13:11:20
maintainerMihail Mishakin
docs_urlNone
authorMihail Mishakin
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ssi-views

A simple Django application to process SSI includes.

[![PyPI](https://img.shields.io/pypi/v/ssi-views.svg)](https://pypi.org/project/ssi-views/)
[![Build Status](https://github.com/dldevinc/ssi-views/actions/workflows/tests.yml/badge.svg)](https://github.com/dldevinc/ssi-views)
[![Software license](https://img.shields.io/pypi/l/ssi-views.svg)](https://pypi.org/project/ssi-views/)

## Compatibility

-   `python` >= 3.9
-   `django` >= 3.2

## Features

-   Supported Function-Based and Class-Based Views
-   One URL pattern ~~to rule them all~~ for all SSI views
-   Jinja2 support

## Installation

Install the latest release with pip:

```shell
pip install ssi-views
```

Add `ssi_views` to your INSTALLED_APPS in django's `settings.py`:

```python
INSTALLED_APPS = [
    "ssi_views",
]
```

Add `ssi_views.urls` to your URLconf:

```python
from django.urls import include, path

urlpatterns = [
    path("ssi/", include("ssi_views.urls")),
]
```

## Usage

#### @ssi_view("name")

Use this decorator to register your views (Function-Based or Class-Based).

```python
from ssi_views.decorators import ssi_view

@ssi_view("myapp.form")
def form_view(request):
    ...

@ssi_view("myapp.form_cbv")
class SSIFormView(FormView):
    ...
```

**NOTE**: The specified name has to be unique.

You can combine `ssi_view` with other decorators:

```python
@csrf_exempt
@require_POST
@ssi_view("myapp.contact_form")
def csrf_exempt_view(request):
    # ...
```

#### {% ssi_include %}

Template tag to render `<!--# include virtual="..." -->` directive.

```djangotemplate
{% load ssi_views %}

{% ssi_include "myapp.form" %}
```

Output:

```html
<!--# include virtual="/ssi/myapp.form/" -->
```

#### {% ssi_url %}

This tag is used to add SSI URLs in the template files:

```djangotemplate
{% load ssi_views %}

<!--# include virtual="{% ssi_url 'myapp.form' %}" -->
```

#### Multiple names

You can have multiple names for the same view:

```python
from ssi_views.decorators import ssi_view

@ssi_view(["myapp.form", "myapp.fallback"])
def example_view(request):
    ...
```

## Jinja2 support

Enable Jinja2 extension

```python
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.jinja2.Jinja2",
        "OPTIONS": {
            "extensions": [
                ...
                "ssi_views.templatetags.ssi_views.SSIIncludeExtension",
            ]
        }
    }
]
```

**NOTE**: If you are using [django-jinja](https://niwinz.github.io/django-jinja/latest/), you don't need to do this.

The usage is similar to Django, except that `ssi_url` is a global function:

```jinja2
<!--# include virtual="{{ ssi_url('myapp.form') }}" -->
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ssi-views",
    "maintainer": "Mihail Mishakin",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": "x896321475@gmail.com",
    "keywords": null,
    "author": "Mihail Mishakin",
    "author_email": "x896321475@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/44/f6/5d589f6972e770d22532c21b8999a196487141d10154611e4728201b6d6c/ssi_views-0.6.0.tar.gz",
    "platform": null,
    "description": "# ssi-views\n\nA simple Django application to process SSI includes.\n\n[![PyPI](https://img.shields.io/pypi/v/ssi-views.svg)](https://pypi.org/project/ssi-views/)\n[![Build Status](https://github.com/dldevinc/ssi-views/actions/workflows/tests.yml/badge.svg)](https://github.com/dldevinc/ssi-views)\n[![Software license](https://img.shields.io/pypi/l/ssi-views.svg)](https://pypi.org/project/ssi-views/)\n\n## Compatibility\n\n-   `python` >= 3.9\n-   `django` >= 3.2\n\n## Features\n\n-   Supported Function-Based and Class-Based Views\n-   One URL pattern ~~to rule them all~~ for all SSI views\n-   Jinja2 support\n\n## Installation\n\nInstall the latest release with pip:\n\n```shell\npip install ssi-views\n```\n\nAdd `ssi_views` to your INSTALLED_APPS in django's `settings.py`:\n\n```python\nINSTALLED_APPS = [\n    \"ssi_views\",\n]\n```\n\nAdd `ssi_views.urls` to your URLconf:\n\n```python\nfrom django.urls import include, path\n\nurlpatterns = [\n    path(\"ssi/\", include(\"ssi_views.urls\")),\n]\n```\n\n## Usage\n\n#### @ssi_view(\"name\")\n\nUse this decorator to register your views (Function-Based or Class-Based).\n\n```python\nfrom ssi_views.decorators import ssi_view\n\n@ssi_view(\"myapp.form\")\ndef form_view(request):\n    ...\n\n@ssi_view(\"myapp.form_cbv\")\nclass SSIFormView(FormView):\n    ...\n```\n\n**NOTE**: The specified name has to be unique.\n\nYou can combine `ssi_view` with other decorators:\n\n```python\n@csrf_exempt\n@require_POST\n@ssi_view(\"myapp.contact_form\")\ndef csrf_exempt_view(request):\n    # ...\n```\n\n#### {% ssi_include %}\n\nTemplate tag to render `<!--# include virtual=\"...\" -->` directive.\n\n```djangotemplate\n{% load ssi_views %}\n\n{% ssi_include \"myapp.form\" %}\n```\n\nOutput:\n\n```html\n<!--# include virtual=\"/ssi/myapp.form/\" -->\n```\n\n#### {% ssi_url %}\n\nThis tag is used to add SSI URLs in the template files:\n\n```djangotemplate\n{% load ssi_views %}\n\n<!--# include virtual=\"{% ssi_url 'myapp.form' %}\" -->\n```\n\n#### Multiple names\n\nYou can have multiple names for the same view:\n\n```python\nfrom ssi_views.decorators import ssi_view\n\n@ssi_view([\"myapp.form\", \"myapp.fallback\"])\ndef example_view(request):\n    ...\n```\n\n## Jinja2 support\n\nEnable Jinja2 extension\n\n```python\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.jinja2.Jinja2\",\n        \"OPTIONS\": {\n            \"extensions\": [\n                ...\n                \"ssi_views.templatetags.ssi_views.SSIIncludeExtension\",\n            ]\n        }\n    }\n]\n```\n\n**NOTE**: If you are using [django-jinja](https://niwinz.github.io/django-jinja/latest/), you don't need to do this.\n\nThe usage is similar to Django, except that `ssi_url` is a global function:\n\n```jinja2\n<!--# include virtual=\"{{ ssi_url('myapp.form') }}\" -->\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple Django application to process SSI includes.",
    "version": "0.6.0",
    "project_urls": {
        "repository": "https://github.com/dldevinc/ssi-views"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5cf508f59a41e8c9e34a2e04ff7b7a0e6fbfc1009d2d4c0a4662cb26a51d2808",
                "md5": "915c47ccb45fcbb68dfb53c1dd9c54d3",
                "sha256": "3c15babfc999bd69b9fa2a36c72a4eac9f75da8e1adccbc1efe599cc478e4e65"
            },
            "downloads": -1,
            "filename": "ssi_views-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "915c47ccb45fcbb68dfb53c1dd9c54d3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 7115,
            "upload_time": "2024-12-20T13:11:19",
            "upload_time_iso_8601": "2024-12-20T13:11:19.373488Z",
            "url": "https://files.pythonhosted.org/packages/5c/f5/08f59a41e8c9e34a2e04ff7b7a0e6fbfc1009d2d4c0a4662cb26a51d2808/ssi_views-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "44f65d589f6972e770d22532c21b8999a196487141d10154611e4728201b6d6c",
                "md5": "4757729fc6e33f1a12fdf84d177ddaa1",
                "sha256": "a26a908df8582323241fa57840abfbb329035d77166163b23862332aeba792dd"
            },
            "downloads": -1,
            "filename": "ssi_views-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4757729fc6e33f1a12fdf84d177ddaa1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 6253,
            "upload_time": "2024-12-20T13:11:20",
            "upload_time_iso_8601": "2024-12-20T13:11:20.488732Z",
            "url": "https://files.pythonhosted.org/packages/44/f6/5d589f6972e770d22532c21b8999a196487141d10154611e4728201b6d6c/ssi_views-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-20 13:11:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dldevinc",
    "github_project": "ssi-views",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ssi-views"
}
        
Elapsed time: 0.50157s