Skip to main content

A simple Django application to process SSI includes.

Project description

ssi-views

A simple Django application to process SSI includes.

PyPI Build Status Software license

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:

pip install ssi-views

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

INSTALLED_APPS = [
    "ssi_views",
]

Add ssi_views.urls to your URLconf:

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).

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:

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

{% ssi_include %}

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

{% load ssi_views %}

{% ssi_include "myapp.form" %}

Output:

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

{% ssi_url %}

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

{% load ssi_views %}

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

Multiple names

You can have multiple names for the same view:

from ssi_views.decorators import ssi_view

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

Jinja2 support

Enable Jinja2 extension

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

NOTE: If you are using django-jinja, you don't need to do this.

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

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

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

ssi_views-0.6.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssi_views-0.6.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file ssi_views-0.6.0.tar.gz.

File metadata

  • Download URL: ssi_views-0.6.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.8 Linux/6.5.0-1025-azure

File hashes

Hashes for ssi_views-0.6.0.tar.gz
Algorithm Hash digest
SHA256 a26a908df8582323241fa57840abfbb329035d77166163b23862332aeba792dd
MD5 4757729fc6e33f1a12fdf84d177ddaa1
BLAKE2b-256 44f65d589f6972e770d22532c21b8999a196487141d10154611e4728201b6d6c

See more details on using hashes here.

File details

Details for the file ssi_views-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: ssi_views-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.8 Linux/6.5.0-1025-azure

File hashes

Hashes for ssi_views-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c15babfc999bd69b9fa2a36c72a4eac9f75da8e1adccbc1efe599cc478e4e65
MD5 915c47ccb45fcbb68dfb53c1dd9c54d3
BLAKE2b-256 5cf508f59a41e8c9e34a2e04ff7b7a0e6fbfc1009d2d4c0a4662cb26a51d2808

See more details on using hashes here.

Supported by

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