Sha256: 9d52a37afc6c86beba22cff4e7e62ab207f5775b88979ef355f8796673d0b04c

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

module Sass::Script
  class Interpolation < Node
    def initialize(before, mid, after, wb, wa)
      @before = before
      @mid = mid
      @after = after
      @whitespace_before = wb
      @whitespace_after = wa
    end

    def inspect
      "(interpolation #{@before.inspect} #{@mid.inspect} #{after.inspect})"
    end

    def to_sass
      res = ""
      res << @before.to_sass if @before
      res << ' ' if @before && @whitespace_before
      res << '#{' << @mid.to_sass << '}'
      res << ' ' if @after && @whitespace_after
      res << @after.to_sass if @after
      res
    end

    def children
      [@before, @mid, @after].compact
    end

    protected

    def _perform(environment)
      res = ""
      res << @before.perform(environment).to_s if @before
      res << " " if @before && @whitespace_before
      val = @mid.perform(environment)
      res << (val.is_a?(Sass::Script::String) ? val.value : val.to_s)
      res << " " if @after && @whitespace_after
      res << @after.perform(environment).to_s if @after
      Sass::Script::String.new(res)
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
haml-edge-2.3.186 lib/sass/script/interpolation.rb
haml-edge-2.3.185 lib/sass/script/interpolation.rb
haml-edge-2.3.184 lib/sass/script/interpolation.rb
haml-3.0.0.beta.1 lib/sass/script/interpolation.rb
haml-edge-2.3.183 lib/sass/script/interpolation.rb
haml-edge-2.3.182 lib/sass/script/interpolation.rb
haml-edge-2.3.181 lib/sass/script/interpolation.rb
haml-edge-2.3.180 lib/sass/script/interpolation.rb