Snippet List
This code will put an entire folder into your media bundle - instead of having to write out every file in a given folder:
*It assumes your static root is a absolute directory*
**Usage**
MEDIA_BUNDLES = (
('init.js',
'coffeescript/init.coffee',
),
bundle_builder('libraries.js', 'javascript/vendor'),
bundle_builder('main.js', 'coffeescript', exclude=['init.js',]),
bundle_builder('templates.js', 'eco'),
)
**Notes**
You may wish to use [cache_utils](http://pypi.python.org/pypi/django-cache-utils) or similar to avoid crawling the filesystem every time the site loads
- django
- wildcard
- django-mediagenerator
- mediagenerator
I needed a way to quickly get a direction of html pages templated such that another person could drop new templates in to a subdirectory and without modifying urls.py or views.py get them up and being displayed.
Now, the direct_to_template view provided django.views.generic.simple can sort of do this with a urlpattern like:
`url(r'^(?P<template>.*\.html)$', direct_to_template)`
But that means your templates, no matter what level in the url hierarchy they are reached at, have to be defined at the root of a template directory. I wanted them retrieved from a specific subdirectory instead so I could provide a little wall for them. Hence this snippet.
To use you would have url pattern that looked like:
`url(r'^foo/(?P<template>.*\.html)$', direct_to_template, {'subdir' : 'subdir/'}),`
Which will template any url that matches <parent url>/foo/bar.html for any 'bar'. The problem is if this is a sub-url pattern match this is going to look for the template "bar.html" when we may actually want it to get the template "<parent url>/foo/bar.html"
- templating
- wildcard
- subdir
2 snippets posted so far.