-def do_get_chunk(parser, token):
- # split_contents() knows not to split quoted strings.
- tokens = token.split_contents()
- if len(tokens) < 2 or len(tokens) > 3:
- raise template.TemplateSyntaxError, "%r tag should have either 2 or 3 arguments" % (tokens[0],)
- if len(tokens) == 2:
- tag_name, key = tokens
- cache_time = 0
- if len(tokens) == 3:
- tag_name, key, cache_time = tokens
- # Check to see if the key is properly double/single quoted
- if not (key[0] == key[-1] and key[0] in ('"', "'")):
- raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
- # Send key without quotes and caching time
- return ChunkNode(key[1:-1], cache_time)