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

github.com/twbs/bootstrap-sass.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Mazovetskiy <glebm@google.com>2015-02-25 05:21:42 +0300
committerGleb Mazovetskiy <glebm@google.com>2015-03-16 18:38:18 +0300
commitc45209470ef548ab2d24def0abaaefff712bb8c5 (patch)
tree0d25075158d276d52d6a0aa4ea5619ba1d9903a2
parent5d3c30a148ae30ab8322f8c38148f99c7f6a8dc5 (diff)
converter: simplify replace_mixins
-rw-r--r--tasks/converter/less_conversion.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/tasks/converter/less_conversion.rb b/tasks/converter/less_conversion.rb
index 2609d5d3..5e69d928 100644
--- a/tasks/converter/less_conversion.rb
+++ b/tasks/converter/less_conversion.rb
@@ -424,16 +424,16 @@ SASS
# #scope > .mixin() -> @include scope-mixin()
# &:extend(.mixin all) -> @include mixin()
def replace_mixins(less, mixin_names)
- mixin_pattern = /(\s+)(([#|\.][\w-]+\s*>\s*)*)\.([\w-]+\(.*\))(?!\s\{)/
-
- less = less.gsub(mixin_pattern) do |match|
- matches = match.scan(mixin_pattern).flatten
- scope = matches[1] && matches[1] != '' ? matches[1].scan(/[\w-]+/).join('-') + '-' : ''
- mixin_name = match.scan(/\.([\w-]+)\(.*\)\s?\{?/).first
- if mixin_name && mixin_names.include?("#{scope}#{mixin_name.first}")
- "#{matches.first}@include #{scope}#{matches.last.gsub(/;\s*\$/, ', $').sub(/;\)$/, ')').sub(/\(\)$/, '')}"
+ mixin_pattern = /(?<=^|\s)((?:[#|\.][\w-]+\s*>\s*)*)\.([\w-]+)\((.*)\)(?!\s\{)/
+
+ less = less.gsub(mixin_pattern) do |_|
+ scope, name, args = $1, $2, $3
+ scope = scope.scan(/[\w-]+/).join('-') + '-' unless scope.empty?
+ args = "(#{args.tr(';', ',')})" unless args.empty?
+ if name && mixin_names.include?("#{scope}#{name}")
+ "@include #{scope}#{name}#{args}"
else
- "#{matches.first}@extend .#{scope}#{matches.last.gsub(/\(\)/, '')}"
+ "@extend .#{scope}#{name}"
end
end