def get_photo(parser, token):
"""Get a single photo from the photologue library and return the img tag to display it.
Takes 3 args:
- the photo to display. This can be either the slug of a photo, or a variable that holds either a photo instance or
a integer (photo id)
- 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, photo, photosize, css_class = token.split_contents()
except ValueError:
msg = '%r tag requires 3 arguments' % token.contents[0]
raise template.TemplateSyntaxError(msg)
return PhotoNode(photo, photosize[1:-1], css_class[1:-1])
评论列表
文章目录