Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

"cms.plugins.snippet" (from djangocms) cloned to extend it with some facilities

Project Description

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;


In the admin, the HTML content will be edited with the djangocodemirror editor.


The only thing needed is to replace the cms.plugins.snippet in your DjangoCMS settings, like this :

    # Plugins
    'snippet', # the snippet plugin clone
    'djangocodemirror', # the editor

Then add :

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


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.

Release History

This version
History Node


History Node


History Node


History Node


History Node

History Node

History Node

History Node

History Node

History Node

History Node

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(10.9 kB) Copy SHA256 Hash SHA256
Source Sep 14, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting