Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

What is the proper way to handle django's static template tag? #268

Closed
anywhim opened this issue Dec 30, 2013 · 2 comments
Closed

What is the proper way to handle django's static template tag? #268

anywhim opened this issue Dec 30, 2013 · 2 comments

Comments

@anywhim
Copy link

anywhim commented Dec 30, 2013

I'm newbie in grunt. I'm use Django to serve static files hence my template looks as:

<link rel="stylesheet" href={% static "bower_components/bootstrap/dist/css/bootstrap.css" %}>
<script src={% static "bower_components/angular/angular.min.js" %}></script>

What is the proper way to handle this url? Should I create task for removing '{%static', '%}' and save result in temporary file?

UPD: I've seen source code sufficient to change regex and output string and it works for me. There are similar problem with htmlmin and bower-install. You could add option to this tasks for my case but I don't know how often needed this usecase. If I chose way with creating temporary file what would I do with bower-install?

@kevinseelbach
Copy link

I'm interested in something similar. Can you point me towards that regex?

@lakenen
Copy link

lakenen commented Jan 20, 2014

I was able to come up with a workaround that doesn't require modifying usemin source (just changing your gruntfile). Doesn't use src="{% static "path/to/file.js" %}" but instead uses a property on the view context STATIC_URL, which you then use like src="{{STATIC_URL}}path/to/file.js". Full solution here: http://stackoverflow.com/a/21224396/494954

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants