File tree Expand file tree Collapse file tree 1 file changed +26
-19
lines changed Expand file tree Collapse file tree 1 file changed +26
-19
lines changed Original file line number Diff line number Diff line change 1
1
module Sprite ::Sass ::Extensions
2
2
def sprite_background ( group , image )
3
3
sprite = sprite_data ( group , image )
4
- # TODO
5
- ""
4
+ if sprite
5
+ "url(http://github.com/'%3Cspan%20class=pl-s1%3E%3Cspan%20class=pl-kos%3E#{%3C/span%3E%3Cspan%20class=pl-s1%3Esprite%3C/span%3E%3Cspan%20class=pl-kos%3E[%3C/span%3E%3Cspan%20class=pl-pds%3E:img%3C/span%3E%3Cspan%20class=pl-kos%3E]%3C/span%3E%3Cspan%20class=pl-kos%3E}%3C/span%3E%3C/span%3E') no-repeat #{ sprite [ :x ] } px #{ sprite [ :y ] } px"
6
+ else
7
+ ""
8
+ end
6
9
end
7
10
8
11
def sprite_width ( group , image )
9
12
sprite = sprite_data ( group , image )
10
- # TODO
11
- ""
13
+ if sprite
14
+ "#{ sprite [ :width ] } px"
15
+ else
16
+ ""
17
+ end
12
18
end
13
19
14
20
def sprite_height ( group , image )
15
21
sprite = sprite_data ( group , image )
16
- # TODO
17
- ""
22
+ if sprite
23
+ "#{ sprite [ :height ] } px"
24
+ else
25
+ ""
26
+ end
18
27
end
19
28
20
29
protected
21
30
def sprite_data ( group , image )
22
31
unless @__sprite_data
23
- @__sprite_data = {
24
- "group_name" => {
25
- "image_name" => {
26
- :width => "" ,
27
- :height => "" ,
28
- :group => "dkajsdfk" ,
29
- :x => "" ,
30
- :y => ""
31
- }
32
- }
33
- }
32
+
33
+ # TODO: read template from !sprite_data
34
+ sprite_data_path = "public/sass/sprites.yml"
35
+
36
+ # figure out the site root
37
+ root = "./"
38
+
39
+ # read sprite data from yml
40
+ @__sprite_data = File . open ( File . join ( root , sprite_data_path ) ) { |yf | YAML ::load ( yf ) }
34
41
end
35
42
36
- group_data = @__sprite_data [ group ]
43
+ group_data = @__sprite_data [ group . to_s ]
37
44
if group_data
38
- return group_data [ image ]
45
+ return group_data [ image . to_s ]
39
46
else
40
47
nil
41
48
end
You can’t perform that action at this time.
0 commit comments