actionview-path_hints 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/actionview/path_hints.rb +18 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32915b43871175e3345b8814c4747dca557b3d98
|
4
|
+
data.tar.gz: 51f91adc876a1e8dff08af204a8a0259668588fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 051f00fa39ab2e9acec4df73347ad1823b9d557ecccf7bb446770a0c94e660c13ad9b955410c2a142212ba3d044e99b333e53d625255d13b00d8dc7b15f1aa88
|
7
|
+
data.tar.gz: ff0d1d2f4b9bb8646ba0a8ab4749e268f643b1d473c897af6d74548d98033e2ea8de6bbba9a8d25704e195fc53028729786f4df400e9de90495b891a63421a18
|
@@ -1,22 +1,33 @@
|
|
1
1
|
module ActionView
|
2
2
|
class PathHints
|
3
|
+
CONTAINER = %w(
|
4
|
+
position:relative
|
5
|
+
border:1px\ solid\ %s
|
6
|
+
)
|
7
|
+
LABEL = %w(
|
8
|
+
font-size:9px
|
9
|
+
background:beige
|
10
|
+
position:absolute
|
11
|
+
top:0
|
12
|
+
left:0
|
13
|
+
)
|
3
14
|
def initialize(view, template)
|
4
15
|
@view = view
|
5
16
|
@template = template
|
6
17
|
end
|
7
18
|
|
8
19
|
def apply(output_buffer)
|
9
|
-
|
10
|
-
|
11
|
-
label_style = "font-size: 9px;background:beige;position:absolute;top:0px;left:0px;"
|
12
|
-
path_hints = "<div style='#{container_style}'>"\
|
13
|
-
"<span style='#{label_style}'>#{@template.inspect}</span>"
|
14
|
-
output_buffer.prepend(path_hints.html_safe).concat('</div>'.html_safe)
|
20
|
+
output_buffer.prepend("<div style='#{styles(sprintf(CONTAINER, cached? ? 'green' : 'red'))}'>"\
|
21
|
+
"<span style='#{styles(LABEL)}'>#{@template.inspect}</span>".html_safe).concat('</div>'.html_safe)
|
15
22
|
end
|
16
23
|
|
17
24
|
private
|
18
25
|
|
19
|
-
def
|
26
|
+
def styles(values)
|
27
|
+
values.each { |value| "#{value}!important;" }.join
|
28
|
+
end
|
29
|
+
|
30
|
+
def cached?
|
20
31
|
rails_latest? ?
|
21
32
|
@view.view_renderer.cache_hits[@template.virtual_path] :
|
22
33
|
@view.view_renderer.lookup_context.cache
|