Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Mazovetskiy <glex.spb@gmail.com>2014-12-17 18:27:37 +0300
committerGleb Mazovetskiy <glex.spb@gmail.com>2014-12-17 18:28:54 +0300
commit7d30630bc8d490239b15dce754dfba298a7d5bc2 (patch)
tree7685bd1aa2e36c996de11624e2da4d5d52a0bcc3
parent19651584e8a669ffe4e72a715275bdcf1acbe7f1 (diff)
Sass: explicitly set $bootstrap-sass-asset-helper
Remove reliance on a hack as a polyfill for `function-exists`. Remove clutter from the generated variables template.
-rw-r--r--assets/stylesheets/_bootstrap-compass.scss2
-rw-r--r--assets/stylesheets/_bootstrap-mincer.scss2
-rw-r--r--assets/stylesheets/_bootstrap-sprockets.scss2
-rw-r--r--assets/stylesheets/bootstrap/_variables.scss9
-rw-r--r--tasks/converter/less_conversion.rb12
-rw-r--r--templates/project/_bootstrap-variables.sass8
6 files changed, 15 insertions, 20 deletions
diff --git a/assets/stylesheets/_bootstrap-compass.scss b/assets/stylesheets/_bootstrap-compass.scss
index 82706c4..8fbc3cd 100644
--- a/assets/stylesheets/_bootstrap-compass.scss
+++ b/assets/stylesheets/_bootstrap-compass.scss
@@ -5,3 +5,5 @@
@function twbs-image-path($path) {
@return image-url($path, true);
}
+
+$bootstrap-sass-asset-helper: true;
diff --git a/assets/stylesheets/_bootstrap-mincer.scss b/assets/stylesheets/_bootstrap-mincer.scss
index 3413250..7ec4657 100644
--- a/assets/stylesheets/_bootstrap-mincer.scss
+++ b/assets/stylesheets/_bootstrap-mincer.scss
@@ -15,3 +15,5 @@
@function twbs-image-path($file) {
@return "<%- asset_path('#{$file}') %>";
}
+
+$bootstrap-sass-asset-helper: true;
diff --git a/assets/stylesheets/_bootstrap-sprockets.scss b/assets/stylesheets/_bootstrap-sprockets.scss
index 7d30692..9fffc1e 100644
--- a/assets/stylesheets/_bootstrap-sprockets.scss
+++ b/assets/stylesheets/_bootstrap-sprockets.scss
@@ -5,3 +5,5 @@
@function twbs-image-path($path) {
@return image-path($path);
}
+
+$bootstrap-sass-asset-helper: true;
diff --git a/assets/stylesheets/bootstrap/_variables.scss b/assets/stylesheets/bootstrap/_variables.scss
index 7d190f2..e23cba0 100644
--- a/assets/stylesheets/bootstrap/_variables.scss
+++ b/assets/stylesheets/bootstrap/_variables.scss
@@ -1,8 +1,4 @@
-// When true, asset path helpers are used, otherwise the regular CSS `url()` is used.
-// When there no function is defined, `fn('')` is parsed as string that equals the right hand side
-// NB: in Sass 3.3 there is a native function: function-exists(twbs-font-path)
-$bootstrap-sass-asset-helper: (twbs-font-path("") != unquote('twbs-font-path("")')) !default;
-
+$bootstrap-sass-asset-helper: false !default;
//
// Variables
// --------------------------------------------------
@@ -82,7 +78,8 @@ $headings-color: inherit !default;
//** Load fonts from this directory.
-// [converter] Asset helpers such as Sprockets and Node.js Mincer do not resolve relative paths
+// [converter] If $bootstrap-sass-asset-helper if used, provide path relative to the assets load path.
+// [converter] This is because some asset helpers, such as Sprockets, do not work with file-relative paths.
$icon-font-path: if($bootstrap-sass-asset-helper, "bootstrap/", "../fonts/bootstrap/") !default;
//** File name for all font files.
diff --git a/tasks/converter/less_conversion.rb b/tasks/converter/less_conversion.rb
index 4b4bf0c..e653575 100644
--- a/tasks/converter/less_conversion.rb
+++ b/tasks/converter/less_conversion.rb
@@ -95,14 +95,10 @@ class Converter
file = apply_mixin_parent_selector file, '\.(?:visible|hidden)'
when 'variables.less'
file = insert_default_vars(file)
- file = unindent <<-SCSS + "\n" + file, 14
- // When true, asset path helpers are used, otherwise the regular CSS `url()` is used.
- // When there no function is defined, `fn('')` is parsed as string that equals the right hand side
- // NB: in Sass 3.3 there is a native function: function-exists(twbs-font-path)
- $bootstrap-sass-asset-helper: #{sass_fn_exists('twbs-font-path')} !default;
- SCSS
+ file = ['$bootstrap-sass-asset-helper: false !default;', file].join("\n")
file = replace_all file, %r{(\$icon-font-path): \s*"(.*)" (!default);}, "\n" + unindent(<<-SCSS, 14)
- // [converter] Asset helpers such as Sprockets and Node.js Mincer do not resolve relative paths
+ // [converter] If $bootstrap-sass-asset-helper if used, provide path relative to the assets load path.
+ // [converter] This is because some asset helpers, such as Sprockets, do not work with file-relative paths.
\\1: if($bootstrap-sass-asset-helper, "bootstrap/", "\\2bootstrap/") \\3;
SCSS
when 'close.less'
@@ -146,7 +142,7 @@ class Converter
# generate variables template
save_file 'templates/project/_bootstrap-variables.sass',
"// Override Bootstrap variables here (defaults from bootstrap-sass v#{Bootstrap::VERSION}):\n\n" +
- File.read("#{save_to}/_variables.scss").gsub(/^(?=\$)/, '// ').gsub(/ !default;/, '')
+ File.read("#{save_to}/_variables.scss").lines[1..-1].join.gsub(/^(?=\$)/, '// ').gsub(/ !default;/, '')
end
def bootstrap_less_files
diff --git a/templates/project/_bootstrap-variables.sass b/templates/project/_bootstrap-variables.sass
index 968ceb6..080b1a3 100644
--- a/templates/project/_bootstrap-variables.sass
+++ b/templates/project/_bootstrap-variables.sass
@@ -1,10 +1,5 @@
// Override Bootstrap variables here (defaults from bootstrap-sass v3.3.1.0):
-// When true, asset path helpers are used, otherwise the regular CSS `url()` is used.
-// When there no function is defined, `fn('')` is parsed as string that equals the right hand side
-// NB: in Sass 3.3 there is a native function: function-exists(twbs-font-path)
-// $bootstrap-sass-asset-helper: (twbs-font-path("") != unquote('twbs-font-path("")'))
-
//
// Variables
// --------------------------------------------------
@@ -84,7 +79,8 @@
//** Load fonts from this directory.
-// [converter] Asset helpers such as Sprockets and Node.js Mincer do not resolve relative paths
+// [converter] If $bootstrap-sass-asset-helper if used, provide path relative to the assets load path.
+// [converter] This is because some asset helpers, such as Sprockets, do not work with file-relative paths.
// $icon-font-path: if($bootstrap-sass-asset-helper, "bootstrap/", "../fonts/bootstrap/")
//** File name for all font files.