django模板标记编译各种静态文件(sass、less、stylus、coffeescript、babel、livescript、handlebar)。
django-static-precompiler的Python项目详细描述
django静态预编译程序
Django静态预编译程序提供模板标记和过滤器来编译coffeescript、livescript、sass/scss、less、stylus、babel和handlebar。 它可以与内联代码和外部文件一起工作。
安装
pip install django-static-precompiler
在模板中使用
{%loadcompile_static%}{%loadstatic%} <script src="{%static"path/to/script.coffee"|compile%}"></script> <link rel="stylesheet" href="{%static"path/to/styles1.less"|compile%}" /> <link rel="stylesheet" href="{%static"path/to/styles2.scss"|compile%}" />
在python中使用
>>>fromstatic_precompiler.utilsimportcompile_static>>>compile_static("styles.scss")"COMPILED/styles.css"