1
0
Fork 0
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:
Gleb Mazovetskiy 2013-12-20 18:03:52 +01:00
parent 115fa1e533
commit cb69362bea
5 changed files with 11 additions and 12 deletions

View file

@ -59,12 +59,7 @@ Require the gem, and load paths and Sass helpers will be configured automaticall
require 'bootstrap-sass' require 'bootstrap-sass'
``` ```
When using outside ruby (e.g. as a bower package), disable ruby asset lookup helper: You can use bootstrap-sass as a Bower package as well.
```sass
$bootstrap-sass-asset-helper: false
```
#### JS and fonts #### JS and fonts

View file

@ -13,6 +13,7 @@ module Sass::Script::Functions
declare :twbs_image_path, [:source] declare :twbs_image_path, [:source]
def twbs_asset_path(source, type) 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) url = if Bootstrap.asset_pipeline? && (context = sprockets_context)
context.send(:"#{type}_path", source.value) context.send(:"#{type}_path", source.value)
elsif Bootstrap.compass? elsif Bootstrap.compass?
@ -23,7 +24,7 @@ module Sass::Script::Functions
url ||= source.value.gsub('"', '') url ||= source.value.gsub('"', '')
Sass::Script::String.new(url, :string) Sass::Script::String.new(url, :string)
end end
declare :twbs_asset_path, [:source] declare :twbs_asset_path, [:source, :type]
unless Sass::Script::Functions.instance_methods.include?(:ie_hex_str) unless Sass::Script::Functions.instance_methods.include?(:ie_hex_str)
# polyfill sass < 3.2.6 (taken from sass 3.2.12): # polyfill sass < 3.2.6 (taken from sass 3.2.12):

View file

@ -74,8 +74,9 @@ class Converter
when 'variables.less' when 'variables.less'
file = insert_default_vars(file) file = insert_default_vars(file)
file = <<-SCSS + file file = <<-SCSS + file
// bootstrap specific variable. set to false if not using ruby + asset pipeline / compass. // whether to use bootstrap-sass asset pipeline / compass integration
$bootstrap-sass-asset-helper: true !default; // defaults to true if twbs-font-path function is present.
$bootstrap-sass-asset-helper: (twbs-font-path('') != unquote("twbs-font-path('')")) !default;
SCSS SCSS
file = replace_all file, /(\$icon-font-path:).*(!default)/, '\1 "bootstrap/" \2' file = replace_all file, /(\$icon-font-path:).*(!default)/, '\1 "bootstrap/" \2'
when 'close.less' when 'close.less'

View file

@ -87,6 +87,7 @@ class Converter
# get sha of the branch (= the latest commit) # get sha of the branch (= the latest commit)
def get_branch_sha def get_branch_sha
return @branch if @branch =~ /[0-9a-f]+/
cmd = "git ls-remote '#@repo_url' | awk '/#@branch/ {print $1}'" cmd = "git ls-remote '#@repo_url' | awk '/#@branch/ {print $1}'"
puts cmd puts cmd
@branch_sha ||= %x[#{cmd}].chomp @branch_sha ||= %x[#{cmd}].chomp
@ -107,4 +108,4 @@ class Converter
JSON.parse get_file(url) JSON.parse get_file(url)
end end
end end
end end

View file

@ -1,5 +1,6 @@
// bootstrap specific variable. set to false if not using ruby + asset pipeline / compass. // whether to use bootstrap-sass asset pipeline / compass integration
$bootstrap-sass-asset-helper: true !default; // defaults to true if twbs-font-path function is present.
$bootstrap-sass-asset-helper: (twbs-font-path('') != unquote("twbs-font-path('')")) !default;
// //
// Variables // Variables
// -------------------------------------------------- // --------------------------------------------------