Sha256: 9612155dc09dd16422677525e403100891ade3d5360d55d740ed810d3b804504
Contents?: true
Size: 1.21 KB
Versions: 8
Compression:
Stored size: 1.21 KB
Contents
module Sprite module Styles # renders standard sass rules class SassGenerator def initialize(builder) @builder = builder end def write(path, sprite_files) @level = 0 File.open(File.join(Sprite.root, path), 'w') do |f| if @builder.config['sprites_class'] f.puts ".#{@builder.config['sprites_class']}" @level += 1 end sprite_files.each do |sprite_file, sprites| background_url = @builder.background_url(sprite_file) sprites.each do |sprite| f.puts sass_line("&.#{sprite[:group]}#{@builder.config['class_separator']}#{sprite[:name]}") @level += 1 f.puts sass_line("background: #{background_url} no-repeat #{sprite[:x]}px #{sprite[:y]}px") f.puts sass_line("width: #{sprite[:width]}px") f.puts sass_line("height: #{sprite[:height]}px") f.puts sass_line("") @level -= 1 end end end end # write sass output with correct tab spaces prepended def sass_line(sass) "#{' '*@level}#{sass}" end def extension "sass" end end end end
Version data entries
8 entries across 8 versions & 1 rubygems