Static URLs in mustache templates

22 views
Skip to first unread message

Filip Jukić

unread,
Oct 16, 2014, 10:20:57 AM10/16/14
to media...@googlegroups.com
Hi all!

It's great the Mediathread has started using Django static files in the templates, but I noticed that mustache templates are still using hardcoded static file URLs (example: https://github.com/ccnmtl/mediathread/blob/master/media/templates/collection.mustache#L8). Is there a way to enable passing of STATIC_URL to all mustache templates somehow? It would really help with hosting static files on an external server or Amazon S3.

Thanks,

Filip

Susan Dreher

unread,
Oct 16, 2014, 1:26:45 PM10/16/14
to media...@googlegroups.com
Hi Filip -

The mustache templates receive a context from the views. I think it would be a simple matter of passing that bit of information down to populate the static_media url. Do you want to take a first pass at this and issue a pull request when you're ready?

Cheers,
Susan

--
You received this message because you are subscribed to the Google Groups "Mediathread" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mediathread...@googlegroups.com.
To post to this group, send email to media...@googlegroups.com.
Visit this group at http://groups.google.com/group/mediathread.
For more options, visit https://groups.google.com/d/optout.

Filip Jukić

unread,
Oct 17, 2014, 11:26:49 AM10/17/14
to media...@googlegroups.com
Hi Susan,

Thanks for the quick reply. I know that it would be possible to pass STATIC_URL from every view to the templates but I was wondering if it is possible to set it only in one place and it would be available to all the mustache templates. Something similar to what django context processors do for regular django templates. I don't do too much javascript work, especially with templating so I'm not sure what is possible and what isn't.

Thanks,

Filip

Susan Dreher

unread,
Oct 17, 2014, 12:10:48 PM10/17/14
to media...@googlegroups.com
Hey -

Unfortunately, I don't think mustache has an equivalent to the context processor at the moment.

Just thinking, and it's a bit of a hack, but maybe relative urls might be an option?

Susan
Reply all
Reply to author
Forward
0 new messages