Skip to content

Commit

Permalink
Merge pull request #16 from jscissr/auto-add
Browse files Browse the repository at this point in the history
Automatically add snippet to db when rendering
  • Loading branch information
bennylope committed Dec 17, 2015
2 parents a91e3fb + 3b033e2 commit 50831f5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addendum/templatetags/addendum_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe

from ..models import get_cached_snippet
from ..models import get_cached_snippet, Snippet


register = template.Library()
Expand Down Expand Up @@ -85,6 +85,8 @@ def render(self, context):

if snippet is None:
output = self.nodelist.render(context)
snippet = Snippet(key=key, text=output)
snippet.save()
return output

if self.template:
Expand Down

0 comments on commit 50831f5

Please sign in to comment.