Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pkolt/django-snippets

Snippet for django
https://github.com/pkolt/django-snippets

Last synced: 7 days ago
JSON representation

Snippet for django

Awesome Lists containing this project

README

        

===============================
Snippets application for Django
===============================

Depending
#########

Python >= 2.6

Django >= 1.3

Installation
############

1. ``snippets`` add INSTALLED_APPS
2. Run ``python manage.py syncdb``

Settings
########

Edit settings.py::

SNIPPETS_PREFIX = 'snippet_'

SNIPPETS = (
'snippets.container.StringSnippet',
'snippets.container.TextSnippet',
'snippets.container.HTMLSnippet',
'snippets.container.CSVSnippet',
'snippets.container.MarkdownSnippet',
)

Formats
#######

* String
* Text
* HTML
* CSV
* Markdown

CSV Snippet
***********

Text::

1, Hello world!
2, Language: Python\, Ruby
3, Escape use \,

In template::

{{ snippet_language.title }}



    {% for num, text in snippet_language.content %}
  • {{ num }}) {{ text }}

  • {% endfor %}

Result::

1) Hello world!
2) Language: Python, Ruby
3) Escape use ,

Templatetags
############

Load tags::

{% load snippets_tags %}

Snippet in template context::

{{ mysnippet.title }}
{{ mysnippet.content }} {# or #} {{ mysnippet }}
{{ mysnippet.raw_content }}

Snippet::

{% snippet "copyright" %} {# show copyright #}

{% snippet "copyright" as copyright %} {# add to context #}

Snippets group::

{% snippets_group "phone" %} {# add to context #}
{{ phone_jon }}, {{ phone_mark }}.

{% snippets_group "phone" as phone_list %}
{% for object in phone_list %}

  • {{ object.title }}: {{ object.content }}

  • {% endfor %}

    Snippet use Shortcode
    ##################

    Use the shortcode in the text ``[snippet name]``.

    In the template, add a filter::

    {{ object.text|snippet_shortcode }}

    Changelog
    #########

    16.04.2012 — Release Snippets version 0.1.4

    09.04.2012 — Release Snippets version 0.1.3

    07.04.2012 — Release Snippets version 0.1.2

    27.03.2012 — Release Snippets version 0.1.0