mirror of
https://github.com/twbs/bootstrap-sass.git
synced 2022-11-09 12:27:02 -05:00
Default $bootstrap-sass-asset-helper to true only if asset helper is
defined. Thanks @cimmanon! See also: http://stackoverflow.com/questions/20706908/test-whether-a-sass-function-is-defined
This commit is contained in:
parent
115fa1e533
commit
cb69362bea
5 changed files with 11 additions and 12 deletions
|
@ -59,12 +59,7 @@ Require the gem, and load paths and Sass helpers will be configured automaticall
|
|||
require 'bootstrap-sass'
|
||||
```
|
||||
|
||||
When using outside ruby (e.g. as a bower package), disable ruby asset lookup helper:
|
||||
|
||||
```sass
|
||||
$bootstrap-sass-asset-helper: false
|
||||
```
|
||||
|
||||
You can use bootstrap-sass as a Bower package as well.
|
||||
|
||||
#### JS and fonts
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ module Sass::Script::Functions
|
|||
declare :twbs_image_path, [:source]
|
||||
|
||||
def twbs_asset_path(source, type)
|
||||
return Sass::Script::String.new('', :string) if source.to_s.empty?
|
||||
url = if Bootstrap.asset_pipeline? && (context = sprockets_context)
|
||||
context.send(:"#{type}_path", source.value)
|
||||
elsif Bootstrap.compass?
|
||||
|
@ -23,7 +24,7 @@ module Sass::Script::Functions
|
|||
url ||= source.value.gsub('"', '')
|
||||
Sass::Script::String.new(url, :string)
|
||||
end
|
||||
declare :twbs_asset_path, [:source]
|
||||
declare :twbs_asset_path, [:source, :type]
|
||||
|
||||
unless Sass::Script::Functions.instance_methods.include?(:ie_hex_str)
|
||||
# polyfill sass < 3.2.6 (taken from sass 3.2.12):
|
||||
|
|
|
@ -74,8 +74,9 @@ class Converter
|
|||
when 'variables.less'
|
||||
file = insert_default_vars(file)
|
||||
file = <<-SCSS + file
|
||||
// bootstrap specific variable. set to false if not using ruby + asset pipeline / compass.
|
||||
$bootstrap-sass-asset-helper: true !default;
|
||||
// whether to use bootstrap-sass asset pipeline / compass integration
|
||||
// defaults to true if twbs-font-path function is present.
|
||||
$bootstrap-sass-asset-helper: (twbs-font-path('') != unquote("twbs-font-path('')")) !default;
|
||||
SCSS
|
||||
file = replace_all file, /(\$icon-font-path:).*(!default)/, '\1 "bootstrap/" \2'
|
||||
when 'close.less'
|
||||
|
|
|
@ -87,6 +87,7 @@ class Converter
|
|||
|
||||
# get sha of the branch (= the latest commit)
|
||||
def get_branch_sha
|
||||
return @branch if @branch =~ /[0-9a-f]+/
|
||||
cmd = "git ls-remote '#@repo_url' | awk '/#@branch/ {print $1}'"
|
||||
puts cmd
|
||||
@branch_sha ||= %x[#{cmd}].chomp
|
||||
|
@ -107,4 +108,4 @@ class Converter
|
|||
JSON.parse get_file(url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// bootstrap specific variable. set to false if not using ruby + asset pipeline / compass.
|
||||
$bootstrap-sass-asset-helper: true !default;
|
||||
// whether to use bootstrap-sass asset pipeline / compass integration
|
||||
// defaults to true if twbs-font-path function is present.
|
||||
$bootstrap-sass-asset-helper: (twbs-font-path('') != unquote("twbs-font-path('')")) !default;
|
||||
//
|
||||
// Variables
|
||||
// --------------------------------------------------
|
||||
|
|
Loading…
Add table
Reference in a new issue