使用bower管理和服务javascript资产的扩展
Flask-Bower的Python项目详细描述
Flask Bower提供了一种管理和服务bower安装包的方法。这大大简化了javascript依赖项管理。
为此,有一个flask blueprint来提供来自bower_components目录的内容,并使用url_for()来提供与从flask static文件夹提供文件相同的文件。
用法
from flask_bower import Bower [...] Bower(app)
现在应该是:
$ ls -1 app/bower_components/jquery MIT-LICENSE.txt bower.json dist src
若要包含和使用它,可以使用url_for():
<script src="{{ url_for('bower.static', filename='jquery/dist/jquery.js') }}"></script>
配置
有几个配置选项可自定义行为:
- BOWER_COMPONENTS_ROOT
默认值:bower_components
包含已安装Bower软件包的目录名
- BOWER_KEEP_DEPRECATED
默认值:True
保持不推荐的功能可用
注意:不推荐的函数将在以后的版本中删除
受影响的功能:
- bower_url_for-请迁移到url_for('bower.static',filename='component/path')
- BOWER_QUERYSTRING_REVVING
默认值:True
追加?version=url的参数(用于更新的缓存破坏)。它尝试按以下顺序检测版本:
- 鲍尔.json
- package.json(如果可用)
- 文件修改时间戳
- BOWER_REPLACE_URL_FOR
默认值:False
替换模板中的烧瓶url_for()函数。
这对为静态文件夹构建“覆盖”很有用,但不推荐使用。
警告:替换url_for()会导致与其他烧瓶扩展(如flask-cdn)冲突,因为一次只能替换一个扩展,而最后注册的扩展将获胜。
- BOWER_SUBDOMAIN
默认值:None
子域提供类似static的内容(请参阅子域的Flask Blueprint文档)
- BOWER_TRY_MINIFIED
默认值:True
检查是否有一个缩小的版本可用并服务于此(检查一个文件是否具有^ {TT32 } $,如^ {TT33 } $)
- BOWER_URL_PREFIX
默认值:/bower
自定义URL前缀
折旧
bower_url_for(component, file)
This is now deprecated since it is a break of the development workflow due to the use of a different function than ^{tt2}$, which is the default for url handling in flask.Since v1.1.0 it is possible to use the default ^{tt2}$ function also for flask assets::url_for('bower.static', filename='component/path')Use of this new approach is recommended to all developers and to simplify the migration the ^{tt39}$ function will stay available for a while; though it can be disabled to help migrating (see ^{tt15}$)
推荐PyPI第三方库
- 热门话题
- java JMX MBean在应用程序部署时自动注册 java如何创建现有JavaFX对象的数组 IntelliJ的java单例线程安全吗 java将Base64编码字符串转换为PDF,无需使用Javascript中的任何库(IE兼容) 使用TestNG运行多个测试套件的java java Firebase/Android:获取当前用户电子邮件 java如何捕获和传播通配符类型参数? java如何在安卓中使用动画翻转图像 菜单和游戏活动之间的java延迟 java如何将对象转换为JSON(不包括属性) java无法在可运行的JavaFX中更改接口 使用jsp/servlet的java清理URL? java grpc示例是否打算跨语言使用? java缺少目标JNDI名称 GridBagLayout中的java非均匀列 java如何在单独的线程中执行大量WS调用并增加单个结果变量? 以前使用数据导入数据时,java无法使用save()进行插入。sql 带有单独收集的java流过滤器