Permalink
Browse files

template kwarg for base ListNode

  • Loading branch information...
1 parent 3837ec4 commit 5399b816d9012c8e1ead14badc6bfabcc3f0c096 @sambixly sambixly committed Jun 23, 2011
Showing with 16 additions and 2 deletions.
  1. +12 −1 apps/base/template_tags.py
  2. +3 −0 templates/listnode_template_text.html
  3. +1 −1 templates/tag_test.html
View
@@ -1,6 +1,6 @@
import random
-from django.template import Node, Variable
+from django.template import Node, Variable, Context, loader
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import AnonymousUser
@@ -137,4 +137,15 @@ def render(self, context):
objects = [item.object for item in items[:limit]]
context[self.context_var] = objects
+
+ if 'template' in self.kwargs:
+ try:
+ template = Variable(self.kwargs['template'])
+ template = unicode(template.resolve(context))
+ except:
+ template = self.kwargs['template']
+
+ t = loader.get_template(template)
+ return t.render(Context(context, autoescape=context.autoescape))
+
return ""
@@ -0,0 +1,3 @@
+{% for item in items %}
+<p></p><b>{{item.id}}</b></p>
+{% endfor %}
View
@@ -28,7 +28,7 @@
{# core apps #}
{% list_pages as items %}
-{% list_articles as items %}
+{% list_articles as items template="listnode_template_text.html" %}
{% list_boxes as items %}
{% list_events as items %}
{% list_jobs as items %}

0 comments on commit 5399b81

Please sign in to comment.