Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @register.tag(name='remote_include')
- def do_remote_include(parser, token):
- """
- Remote include of an URL, replacing some variables, and caching the output for a certain amount of seconds
- {% remote_include http://remote.com/test/%s/%s/ 360 arg_1 arg_2 %}
- """
- bits = token.contents.split()[1:]
- try:
- url = bits.pop(0)
- except:
- raise ValueError('remote_include requires at least an URL parameter')
- try:
- cache_time = int(bits.pop(0))
- except ValueError:
- cache_time = 60
- try:
- args = bits[:]
- except:
- args = list()
- return RemoteIncludeNode(url, cache_time, args)
Advertisement
Add Comment
Please, Sign In to add comment