Hi Bernhard,

Yes, on quick glance this looks like a bug. It looks like all replacements 
get applied to all matching files. Feel free to open a ticket if you 
haven't. (If you have, feel free to link to it in case someone else finds 
this.)

Collin

On Saturday, December 6, 2014 3:29:53 PM UTC-5, Bernhard Mäder wrote:
>
> Hey guys,
>
> HashedFileMixin's pattern variable looks like it could be extended for 
> other file types:
>
> class HashedFilesMixin(object):    
>     default_template = """url("%s")"""
>     patterns = (
>         ("*.css", (
>             r"""(url\(['"]{0,1}\s*(.*?)["']{0,1}\))""",
>             (r"""(@import\s*["']\s*(.*?)["'])""", """@import url("%s")
> """),
>         )),
>     )
>
>
> But - if I read the code right - it can't. Because in post_process, the 
> patterns are applied to all files matched by any of the extensions. 
>
> What I like to be able to achieve is get cache busting in some of my js 
> files as well. I marked all static file references in my code with a 
> 'staticFile()' call and then tried to customize django's 
> CachedStaticFilesStorage like this:
>
> class MyCachedStaticFilesStorage(django.contrib.staticfiles.storage.
> CachedStaticFilesStorage):
>     patterns = django.contrib.staticfiles.storage.HashedFilesMixin.patterns 
> + (
>         (u'*.js', [
>             (r"""(staticFile\(['"]{0,1}\s*(.*?)["']{0,1}\))""", r
> """staticFile("%s")""", )
>         ]),
>     )
>
>
> As of today, that won't work, since all CSS rules are applied to my JS, 
> too, which causes some stuff to be replaced that shouldn't.
>
> Is this a bug, and should I file a bug report? Is it worth fixing? How 
> else can I get cache busting into JS files?
>
> Thanks,
> Bernhard
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6688347d-5607-4ed2-a4ff-850429e6a390%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to