create a template tag django
//
example of some of the stuff in ellington.core.parts.templatetags to make life easier when creating tags...
This is pretty beta, so at this point some stuff might not function as desired.. The function/model doc's in the code are ok..
*above is a 'should work' version of the tag you were talking about friday*
the above code would create a template tag {% get_gallery_list %} which takes to kwarg's .. (categories, as), categories will be passed into the GalleryByCategoryNode as is, but as will be remapped to variable_name since as is a reserved keyword in python... Your class variable self.categories__in will get turned into the galleries.get_list(categories__in=()) .. That variable name might have to be changed to self.category__slug__in, .....etc.. to work...
yeah basically it creates the whole def get_gallery_list(parser, tokens):
#.. do a bunch of argument parsing
return MyNodeClass(**kwargs)
example of some of the stuff in ellington.core.parts.templatetags to make life easier when creating tags...
This is pretty beta, so at this point some stuff might not function as desired.. The function/model doc's in the code are ok..
*above is a 'should work' version of the tag you were talking about friday*
the above code would create a template tag {% get_gallery_list %} which takes to kwarg's .. (categories, as), categories will be passed into the GalleryByCategoryNode as is, but as will be remapped to variable_name since as is a reserved keyword in python... Your class variable self.categories__in will get turned into the galleries.get_list(categories__in=()) .. That variable name might have to be changed to self.category__slug__in, .....etc.. to work...
yeah basically it creates the whole def get_gallery_list(parser, tokens):
#.. do a bunch of argument parsing
return MyNodeClass(**kwargs)
from ellington.core.parts.templatetags import GetListNode, get_kwarg_templatetag class GalleryByCategoryNode(GetListNode): model = Gallery def __init__(self, categories='', variable_name='gallery_list'): self.categories__in = categories.split(',') register.tag(get_kwarg_templatetag( name='get_gallery_list', doc="""Example: {% get_gallery_list categories sports,outdoors %} from django.core import template t = template.Template("{% load photogalleries %} {% get_gallery_list categories sports as my_galleries%}{{ my_galleries }}") """, node_class=GalleryByCategoryNode, remap_arguments=(('as', 'variable_name'),),