Skip to content

Commit

Permalink
add stand-alone cachebuster template tag
Browse files Browse the repository at this point in the history
  • Loading branch information
meeb committed Apr 30, 2022
1 parent f2952d1 commit 7f8a257
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ is available, otherwise it will be the current date in `YYYYMMDDHHMMSS` format.
If there are existing query string parameters then the `tag` is intelligently
appended. The `cdnstatic` tag will not break the existing URL.

Additionally, if you need to just access the `[random tag]` for some other use
without the automatic URL rewriting you can use the following:

```html
<a href="/someurl.html?tag={% cdntag %}">link</a>
```

This can be used in conjunction with other URL wrapping tags for combatability
where chaining tags is difficult, for example:

```html
<link rel="stylesheet" href="{% sass_src 'file.scss' %}?tag={% cdntag %}">
```

# Contributing

All properly formatted and sensible pull requests, issues and comments are
Expand Down
5 changes: 5 additions & 0 deletions django_cachekiller/templatetags/cdnstaticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ def render(self, context):
def do_cdnstatic(parser, token):
url = do_static(parser, token)
return CDNStaticURLNode(url)


@register.tag('cdntag')
def do_cdntag(parser, token):
return refcache.get_ref()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages


version = '0.7.1'
version = '0.8.0'


with open('README.md', 'rt') as f:
Expand Down

0 comments on commit 7f8a257

Please sign in to comment.