Sha256: 4047287023a84550abdebe8a7fae98d5f0c5f2e1f8bdf631a8119385df78b5aa
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 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| sprites.each do |sprite| f.puts sass_line("&.#{sprite[:group]}#{@builder.config['class_separator']}#{sprite[:name]}") @level += 1 f.puts sass_line("background: url('/#{@builder.config['image_output_path']}#{sprite_file}') 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
amikula-sprite-0.1.13 | lib/sprite/styles/sass_generator.rb |
amikula-sprite-0.1.12 | lib/sprite/styles/sass_generator.rb |