Package: jinja2modern
# Jinja2 ModernJinja2 tags for modern web. Includes sass, scss, less, coffee, uglify. Can be easily extended for any command line tools.Preprocessors not running if source files not changed.## Instalationpip install jinja2modern## UsageIn your project directory create settings.py, guess you already have it, with settings:### Basic settings:```python#home pathJINJA2MODERN_HOME = os.path.realpath(os.path.dirname(__file__))#media path relative to home directoryJINJA2MODERN_MEDIA_PATH = 'media'#media urlJINJA2MODERN_MEDIA_URL = '/media'```### EnginesThere are several preprocessor engine directories that you will need in your project. Here is how you can get them:```pythonJINJA2MODERN_ENGINES = {'coffee': '/path/to/coffee/bin/coffee','uglify': '/path/to/uglify/bin/uglifyjs','lesscss': '/path/to/lesscss/bin/lessc','sass': '/path/to/sass/bin/sass',}```### TemplatesYou always can overide basic templates by placing it in tags subdirectory in your jinja2 environment template directory####js.html:<script src="{{ file_link }}"></script>####css.html:<link rel="stylesheet" type="text/css" href="{{ file_link }}" />## Tags### Less, Sass, ScssAll of this template code:```{% less "style.css" %}less/style.less{% endless %}``````{% less "less/style.less" %}```will render tags/css.html, for default template:`<link rel="stylesheet" type="text/css" href="/media_url/css/style.css" />`Of course you can specify out path and file name```{% less "path/to/style.css" %}less/style.less{% endless %}```this will render tags/css.html, for default template:`<link rel="stylesheet" type="text/css" href="/media_url/path/to/style.css" />`### JavascriptJs tag just copy files to media path```{% js "js/main/main.js" %}```this will render tags/js.html, for default template:`<script src="/media_url/js/main.js"></script>`#### Advanced js tag using:You can specify librarys for using in your templates by set this in your settings.py```pythonJINJA2MODERN_JS_LIBS_PATH = 'js/libs'JINJA2MODERN_JS_LIBS = {'jquery': {'src': 'js/lib/jquery*.js','template': 'js/jquery.html'},}```and then just use```{% js "jquery" %}```this will render template js/jquery.html```<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><script>window.jQuery || document.write('<script src="{{ file_link }}"><\/script>')</script>```### Coffee scriptAll of this template code:```{% coffee "js/main/main.coffee" %}``````{% coffee "main.js" %}js/main/main.coffee{% endcoffee %}``````{% coffee "main.js" %}js/main/main1.coffeejs/main/main2.coffeejs/main/main3.coffee{% endcoffee %}```will render tags/js.html, for default template:`<script src="/media/url/js/main.js"></script>`and of course you can specify out path and file name like for less tag.### UglifyJSAll of this template code:```{% uglify "js/main/main.js" %}``````{% uglify "main.js" %}js/main/main.js{% enduglify %}``````{% uglify "main.js" %}js/main/main1.jsjs/main/main2.jsjs/main/main3.js{% enduglify %}```will render tags/js.html, for default template:`<script src="/media/url/js/main.js"></script>`### Advanced coffee and uglify tag using:__In this case uglify will run on every template rendering__```{% coffee "main.js" %}js/main/main1.coffeejs/main/main2.coffeejs/main/main3.coffee{% endcoffee %}{% uglify %}/media/url/js/main.js{% enduglify %}```Coffee tag will produce `/media/url/js/main.js` and render tags/js.html template. Than uglify will compress this file and will not render any templates.