#NEWLINE# def jellyrender( parser , token ) : #NEWLINE# #INDENT# '\n    Render a jellyroll ``Item`` by passing it through a snippet template.\n    \n    ::\n    \n        {% jellyrender <item> [using <template>] [as <varname>] %}\n    \n    A sub-template will be used to render the item. Templates will be searched\n    in this order:\n\n        * The template given with the ``using <template>`` clause, if given.\n    \n        * ``jellyroll/snippets/<classname>.html``, where ``classname`` is the\n          name of the specific item class (i.e. ``photo``).\n          \n        * ``jellyroll/snippets/item.html``.\n        \n    The template will be passed a context containing:\n    \n        ``item``\n            The jellyroll ``Item`` object\n    \n        ``object``\n            The actual object (i.e. ``item.object``).\n            \n    The rendered content will be displayed in the template unless the ``as\n    <varname>`` clause is used to redirect the output into a context variable.\n    ' #NEWLINE# bits = token . split_contents ( ) #NEWLINE# if ( len ( bits ) < 2 ) : #NEWLINE# #INDENT# raise template . TemplateSyntaxError ( ( '%r tag takes at least one argument' % bits [ 0 ] ) ) #NEWLINE# #UNINDENT# item = bits [ 1 ] #NEWLINE# args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( len ( bits ) > 2 ) : #NEWLINE# #INDENT# biter = iter ( bits [ 2 : ] ) #NEWLINE# for bit in biter : #NEWLINE# #INDENT# if ( bit == 'using' ) : #NEWLINE# #INDENT# args [ 'using' ] = biter . next ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( bit == 'as' ) : #NEWLINE# #INDENT# args [ 'asvar' ] = biter . next ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise template . TemplateSyntaxError ( ( '%r tag got an unknown argument: %r' % ( bits [ 0 ] , bit ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return JellyrenderNode ( item , ** args )