diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2013-12-21 08:53:50 +0400 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2013-12-21 08:53:50 +0400 |
commit | 5bd81ba89df10ce1650022b5d2b763fb5ed615b6 (patch) | |
tree | e1af575d97baf2068cbc8d35404061fd4fede27c | |
parent | f076f64a4a3524f6791a1d04e63a9ed107ea919a (diff) |
converter: cleanup, improve asset-helper variable comment
-rw-r--r-- | tasks/converter/less_conversion.rb | 46 | ||||
-rw-r--r-- | vendor/assets/stylesheets/bootstrap/_variables.scss | 5 |
2 files changed, 22 insertions, 29 deletions
diff --git a/tasks/converter/less_conversion.rb b/tasks/converter/less_conversion.rb index 599a415e..092b078a 100644 --- a/tasks/converter/less_conversion.rb +++ b/tasks/converter/less_conversion.rb @@ -84,10 +84,11 @@ class Converter file = extract_nested_rule file, ' a&:' when 'variables.less' file = insert_default_vars(file) - file = <<-SCSS + file -// 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; + file = unindent <<-SCSS + file, 14 + // a flag to toggle asset pipeline / compass integration + // defaults to true if twbs-font-path function is present (no function => twbs-font-path('') parsed as string == right side) + // in Sass 3.3 this can be improved with: function-exists(twbs-font-path) + $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' @@ -126,21 +127,19 @@ $bootstrap-sass-asset-helper: (twbs-font-path('') != unquote("twbs-font-path('') end # apply general less to scss conversion - def convert_to_scss(file) - # mixins may also be defined in the file. get mixin names before doing any processing - mixin_names = (@shared_mixins + read_mixins(file)).uniq - file = replace_vars(file) - file = replace_file_imports(file) - file = replace_mixin_definitions file - file = replace_mixins file, mixin_names - # replace_less_extend does not seem to do anything. @glebm - file = replace_less_extend(file) - file = replace_spin(file) - file = replace_image_urls(file) - file = replace_escaping(file) - file = convert_less_ampersand(file) - file = deinterpolate_vararg_mixins(file) - file = replace_calculation_semantics(file) + def convert_to_scss(file) + # get local mixin names before converting the definitions + mixins = @shared_mixins + read_mixins(file) + file = replace_vars(file) + file = replace_file_imports(file) + file = replace_mixin_definitions(file) + file = replace_mixins(file, mixins) + file = replace_spin(file) + file = replace_image_urls(file) + file = replace_escaping(file) + file = convert_less_ampersand(file) + file = deinterpolate_vararg_mixins(file) + file = replace_calculation_semantics(file) file end @@ -354,7 +353,7 @@ $bootstrap-sass-asset-helper: (twbs-font-path('') != unquote("twbs-font-path('') end end - # Replaces the following: + # @include and @extend from LESS: # .mixin() -> @include mixin() # #scope > .mixin() -> @include scope-mixin() # &:extend(.mixin all) -> @include mixin() @@ -422,13 +421,6 @@ $bootstrap-sass-asset-helper: (twbs-font-path('') != unquote("twbs-font-path('') less end - # #gradient > .horizontal() - # to: - # @include .horizontal-gradient() - def replace_less_extend(less) - less.gsub(/\#(\w+) \> \.([\w-]*)(\(.*\));?/, '@include \1-\2\3;') - end - def replace_spin(less) less.gsub(/(?![\-$@.])spin(?!-)/, 'adjust-hue') end diff --git a/vendor/assets/stylesheets/bootstrap/_variables.scss b/vendor/assets/stylesheets/bootstrap/_variables.scss index 0e812acb..da3c044a 100644 --- a/vendor/assets/stylesheets/bootstrap/_variables.scss +++ b/vendor/assets/stylesheets/bootstrap/_variables.scss @@ -1,5 +1,6 @@ -// whether to use bootstrap-sass asset pipeline / compass integration -// defaults to true if twbs-font-path function is present. +// a flag to toggle asset pipeline / compass integration +// defaults to true if twbs-font-path function is present (no function => twbs-font-path('') parsed as string == right side) +// in Sass 3.3 this can be improved with: function-exists(twbs-font-path) $bootstrap-sass-asset-helper: (twbs-font-path('') != unquote("twbs-font-path('')")) !default; // // Variables |