A simple Django application to process SSI includes
Project description
ssi-views
A simple Django application to process SSI includes
Compatibility
django
>= 1.11python
>= 3.5
Features
- Supported Function-Based and Class-Based Views
- One URL pattern
to rule them allfor all SSI views - Jinja2 support
Installation
Install the package via Pip:
pip install ssi-views
Add it to your INSTALLED_APPS
list:
INSTALLED_APPS = (
...
'ssi_views',
)
Add ssi_views.urls
to your URLconf:
urlpatterns = patterns('',
...
# Django >= 2.0
path('ssi/', include('ssi_views.urls')),
# Django < 2.0
url(r'^ssi/', include('ssi_views.urls', namespace='ssi_views')),
)
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 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') }}" -->
Development and Testing
After cloning the Git repository, you should install this in a virtualenv and set up for development:
virtualenv .venv
source .venv/bin/activate
pip install -r ./requirements.txt
pre-commit install
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 ssi_views-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 695227fb2e2e16b6190c924d8c09b1848af80770c51d1ecd4f15909a59cee1be |
|
MD5 | 86e770df21f0b0a183751e3fde87a881 |
|
BLAKE2b-256 | 639d5924f6be36e1568433f30c32e1a7a8fadce579104c53b0796247e1d16669 |