@register.tag
def staticpage_url(parser, token):
 bits = token.split_contents()
 syntax_message = ("%(tag_name)s expects a syntax of %(tag_name)s 'virtual/path'" % dict(tag_name=bits[0]))
 quote_message = ("%s tag's argument should be in quotes" % bits[0])
 if (len(bits) == 2):
  virtual_path = bits[1]
  if (not ((virtual_path[0] == virtual_path[(-1)]) and (virtual_path[0] in ('"', "'")))):
   raise template.TemplateSyntaxError(quote_message)
  return StaticPageURLNode(virtual_path[1:(-1)])
 raise template.TemplateSyntaxError(syntax_message)

@ register . tag def staticpage_url ( parser , token ) : bits = token . split_contents ( ) syntax_message = ( "%(tag_name)s expects a syntax of %(tag_name)s 'virtual/path'" % dict ( tag_name = bits [ 0 ] ) ) quote_message = ( "%s tag's argument should be in quotes" % bits [ 0 ] ) if ( len ( bits ) == 2 ) : virtual_path = bits [ 1 ] if ( not ( ( virtual_path [ 0 ] == virtual_path [ ( - 1 ) ] ) and ( virtual_path [ 0 ] in ( '"' , "'" ) ) ) ) : raise template . TemplateSyntaxError ( quote_message ) return StaticPageURLNode ( virtual_path [ 1 : ( - 1 ) ] ) raise template . TemplateSyntaxError ( syntax_message )
returns the internal url for a static page based on its virtual path .