Module | Less::StyleSheet::Mixin4 |
In: |
lib/sass/less.rb
|
Selector mixins that don‘t have arguments. This depends only on the syntax at the call site; if it doesn‘t use parens, it hits this production, regardless of whether the mixin being called has arguments or not.
build | -> | build_without_sass |
# File lib/sass/less.rb, line 15 15: def build_with_sass(env) 16: selectors.build(env, :mixin).each do |path| 17: el = path.inject(env.root) do |current, node| 18: current.descend(node.selector, node) or raise MixinNameError, "#{selectors.text_value} in #{env}" 19: end 20: if el.is_a?(Node::Mixin::Def) 21: # Calling a mixin with arguments, which gets compiled to a Sass mixin 22: env << Node::Mixin::Call.new(el, [], env) 23: else 24: # Calling a mixin without arguments, which gets compiled to @extend 25: sel = selector_str(path) 26: base = selector_str(selector_base(path)) 27: if base == sel 28: env << Node::SassNode.new(Sass::Tree::ExtendNode.new([sel])) 29: else 30: Haml::Util.haml_warn "WARNING: Sass doesn't support mixing in selector sequences.\nReplacing \"\#{sel}\" with \"@extend \#{base}\"\n" 31: env << Node::SassNode.new(Sass::Tree::CommentNode.new("// #{sel};", true)) 32: env << Node::SassNode.new(Sass::Tree::ExtendNode.new([base])) 33: end 34: end 35: end 36: end
# File lib/sass/less.rb, line 44 44: def selector_base(path) 45: el, i = Haml::Util.enum_with_index(path).to_a.reverse.find {|e, i| e.selector !~ /^:{1,2}$/} || 46: [path.first, 0] 47: sel = (el.selector =~ /^:{0,2}$/ ? el.selector : "") 48: [Node::Element.new(el.name, sel)] + path[i+1..-1] 49: end