This is a “cms.plugins.snippet” (from djangocms) cloned to extend it with some facilities.
Original code is from the original DjangoCMS plugin.
Changes from original code
This clone try to change as few orignal code as possible, actually the differences are :
Adding a template tag to directly use snippet fragments in the templates, not only from CMS pages;
Add usage of djangocodemirror for the HTML editor;
Add a slug field;
Requires
Django 1.4 to 1.6;
DjangoCMS version 2.3.6 to 3.0.x;
djangocodemirror 0.9.x;
In the admin, the HTML content will be edited with the djangocodemirror editor.
Install
The only thing needed is to replace the cms.plugins.snippet in your DjangoCMS settings, like this :
INSTALLED_APPS = (
'cms',
# Plugins
...
#'cms.plugins.snippet',
'snippet', # the snippet plugin clone
'djangocodemirror', # the editor
...
)
Then add :
CODEMIRROR_SETTINGS = {
'cms_snippet': {
'mode': {'name': "jinja2", 'htmlMode': True},
'lineWrapping': True,
'lineNumbers': True,
'search_enabled': True,
'embed_settings': True,
'add_jquery': True,
'lib_buttons_path': 'djangocodemirror/snippet_buttons.js',
},
}
Because the code is cloned from the original plugin with just a few changes, all CMS stuff should work as with the original plugin, you should even add it in an existing install without loss in database and without any syncdb.
Usage
Template tags
Use the template tags in your templates :
{% load snippet_tags %}
{% snippet_fragment [Snippet ID or slug or instance] %}
Like this :
{% load snippet_tags %}
{% snippet_fragment 42 %}
Or with the slug :
{% load snippet_tags %}
{% snippet_fragment 'my-snippet' %}
The first argument is required, you can use either
The Snippet ID;
The Snippet slug;
The Snippet instance.
Use as a template block with fallback :
{% snippet_fragment 'my-snippet' or %}
... clumsy safe ...
{% endsnippet_fragment %}
In case there is no snippet instance/id/slug, fallback template will be rendered.
Metadata
Release files for emencia-cms-snippet 2.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| emencia-cms-snippet-2.4.2.tar.gz | 10.9 kB | Without provenance | Details for emencia-cms-snippet-2.4.2.tar.gz |
Release files / emencia-cms-snippet-2.4.2.tar.gz
| Download URL | emencia-cms-snippet-2.4.2.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6d69c335f0914b17357af7ac937351f8ab744de5568521d25db511e66cf8283
|
|
BLAKE2b-256 checksum How to use checksums |
8bc96c53af23a21cb942a7ac627b66c54fa09b1d3ba2ff797ead4d3b074864f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for emencia-cms-snippet 2.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.