Skip to content

Commit

Permalink
Merge pull request twbs#15 from yabawock/issue-5
Browse files Browse the repository at this point in the history
Use @extend if no mixin exists (Closes twbs#5)
  • Loading branch information
sporkd committed Jul 30, 2013
2 parents b7ac976 + 7058cf7 commit 14ae4a2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tasks/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
class Converter
def initialize(branch)
@branch = branch || 'master'
@mixins = get_mixins_name
end

def process
Expand Down Expand Up @@ -103,7 +104,7 @@ def get_mixins_name
less_mixins = open("https://raw.github.com/twitter/bootstrap/#{@branch}/less/mixins.less").read

less_mixins.scan(/\.([\w-]+)\(.*\)\s?{?/) do |mixin|
mixins << mixin
mixins << mixin.first
end

mixins
Expand Down Expand Up @@ -141,7 +142,13 @@ def replace_mixins(less)
if scope != ''
scope = scope.scan(/[\w-]+/).join('-') + '-'
end
"#{matches.first}@include #{scope}#{matches.last}"
mixin_name = match.scan(/\.([\w-]+)\(.*\)\s?{?/).first

if mixin_name && @mixins.include?(mixin_name.first)
"#{matches.first}@include #{scope}#{matches.last}".gsub(/; \$/,', $')
else
"#{matches.first}@extend .#{scope}#{matches.last.gsub(/\(\)/, '')}"
end
end
end

Expand Down

0 comments on commit 14ae4a2

Please sign in to comment.