realtyhub / bootstrap-bundle
此包已被弃用,不再维护。没有建议的替代包。
此包最新版本(dev-master)没有可用的许可证信息。
Symfony2 Bundle,包含与Twitter Bootstrap相关的有用工具
dev-master
2018-04-24 10:28 UTC
Requires
- php: >=5.3.3
- slik/dompdf-bundle: dev-master
- symfony/framework-bundle: ~2.3
- symfony/twig-bundle: ~2.3
This package is not auto-updated.
Last update: 2022-10-01 06:27:32 UTC
README
Bootstrap Bundle
Symfony2 Bundle for Twitter Boostrap
目前,此包只有一个目的。它将允许您的应用使用LESS文件,访问Twitter Bootstrap的variables.less中的变量。
安装和配置
Composer.json
{
...
"require": {
"realtyhub/bootstrap-bundle": "dev-master"
}
}
AppKernel.php
<?php public function registerBundles() { $bundles = array( // ... new FOS\UserBundle\FOSUserBundle(), ); }
config.yml
realtyhub_bootstrap: variables_less_path: "/path/to/variables.less"
基本用法
在Twig文件内部
{% stylesheets '@YourBundle/path/to/file.less' filter='bootstrap_variables your_prefered_less_filter' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
警告
您需要确保在运行bootstrap_variables过滤器之前没有意外运行less过滤器。这通常发生在您的config.yml中存在类似以下内容时
assetic: filters: less: node: /usr/bin/node node_paths: [/usr/lib/node_modules] apply_to: "\.less$"
此过滤器将在"inline"的bootstrap_variables过滤器之前运行,因此LESS将无法访问变量,并且很可能无法编译。
这就是为什么建议使用替代用法的原因。
替代用法
config.yml
assetic: filters: bootstrap_variables: resource: 'assetic.xml' #workaround for assetic to accept our filter. #see https://github.com/symfony/AsseticBundle/issues/50 apply_to: "\.less$" less: #Adjust paths to your environment node: /usr/bin/node node_paths: [/usr/lib/node_modules] apply_to: "\.less$"
现在在Twig文件中,您不需要指定过滤器,可以尝试以下内容
{% stylesheets '@YourBundle/path/to/file.less' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
待办事项
- 更好地与braincrafted bootstrap bundle集成。是否有可能自动确定variables.less的路径,并消除配置的需要?