def get_rotating_photo(parser, token):
"""Pick at random a photo from a given photologue gallery and return the img tag to display it.
Takes 3 args:
- the gallery to pick a photo from. This can be either the slug of a gallery, or a variable that holds either a
gallery instance or a gallery slug.
- the photosize to use.
- a CSS class to apply to the img tag.
"""
try:
# Split the contents of the tag, i.e. tag name + argument.
tag_name, gallery, photosize, css_class = token.split_contents()
except ValueError:
msg = '%r tag requires 3 arguments' % token.contents[0]
raise template.TemplateSyntaxError(msg)
return PhotoGalleryNode(gallery, photosize[1:-1], css_class[1:-1])
评论列表
文章目录