github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

semente / django-snippets forked from zerok/django-flatblocks

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 4
    • 3
  • Source
  • Commits
  • Network (3)
  • Issues (0)
  • Downloads (3)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (3)
    • fix-0.1.1-setup
    • gh-pages
    • master ✓
  • Tags (3)
    • 0.1.2
    • 0.1.1
    • 0.1
Sending Request…
Click here to lend your support to: django-snippets and make a donation at www.pledgie.com ! Edit Pledgie Setup

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Dynamic template snippets for Django. — Read more

  cancel

http://github.com/semente/django-snippets/

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

.gitignore updated. 
semente (author)
Tue Oct 27 19:05:11 -0700 2009
commit  830ca9d7844ecf33e1911a20b11a8d69665efd85
tree    aa761e75a1ec12d0abca0b9caff2900c5ad01d30
parent  1d3024583b30bf53223cb5b89d82f1686bae90cd
django-snippets /
name age
history
message
file .gitignore Tue Oct 27 19:05:11 -0700 2009 .gitignore updated. [semente]
file AUTHORS.txt Sun Feb 01 20:55:42 -0800 2009 Updated authors and file README.rst. [semente]
file LICENSE.txt Loading commit data...
file MANIFEST.in Tue Jan 20 08:25:03 -0800 2009 Updated MANIFEST.in [zerok]
file README.rst Tue Oct 27 12:50:34 -0700 2009 Minor changes. [semente]
file ez_setup.py Tue Oct 27 18:34:50 -0700 2009 Fixed a bug in setup.py. [semente]
file setup.py Tue Oct 27 18:57:10 -0700 2009 Merged changes. [semente]
directory snippets/
README.rst

django-snippets

django-snippets provides a templatetag acting as an {% include %}, that loads a template and renders it with the current context, but the template content comes from database.

django-snippets is a fork of django-flatblocks, and the main difference is that django-snippets render the content as a Django template.

Usage

Once you've created some instances of the snippets.models.Snippet model, you can load it it using the snippets templatetag-library:

{% load snippets ... %}

...

{% get_comment_list for entry as comment_list  %}
{% if comment_list %}
  <h2>Comments</h2>
  <ol>{% include_snippet "comment_list" %}</ol>
{% endif %}

This way you can include a snippet with the name "comment_list". If you have the name of a snippet in a template variable, leave out the quotes.

comment_list will be rendered as a Django template. This mean that you can use {% for %}, {% if %} and others template tags.

This tag also accepts an optional argument where you can specify the number of seconds, the that snippet should be cached:

{% include_snippet "comment_list" 3600 %}

If you use a snippet that doesn't exist, ``include_snippet`` will insert the value of the SNIPPET_STRING_IF_INVALID setting, which is '' (the empty string) by default.

License

django-snippets is available free software under the New BSD license. See the file LICENSE.txt for more information.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server