actionview-path_hints 0.0.1
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 +7 -0
- data/lib/action_view/path_hints.rb +45 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4f1e1a9420901d9b6eef1b55b49fd6434c74882d
|
4
|
+
data.tar.gz: a1e54f017fc07a4aa4baa69c1581b5d4a568f915
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f8667a6bc25fcfb2dd120a768050ef35b4b75161123efa32e289b590752a250dd36d4775a10b7e3c012315a46d7b5eb68ba5f0cbe6f6dd9c0d70a66db1426b6
|
7
|
+
data.tar.gz: bffe216b00d1d1e568c97f34a3690b81a334b8cfdd1adb32ab03b5710d6b128e9ada0ac67e82c565ba7d2c289d80bc078937ef14ec40fa3fd316e04acc335b75
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ActionView
|
2
|
+
class PathHints
|
3
|
+
def self.apply(view, template, output_buffer)
|
4
|
+
cache_hit = view.view_renderer.cache_hits[template.virtual_path]
|
5
|
+
cache_color = cache_hit.nil? ? 'red' : 'green'
|
6
|
+
container_style = "position: relative;border:1px solid #{cache_color}!important;"
|
7
|
+
label_style = "font-size: 9px;background:beige;position:absolute;top:0px;left:0px;"
|
8
|
+
path_hints = "<div style='#{container_style}'>"\
|
9
|
+
"<span style='#{label_style}'>#{template.inspect}</span>"
|
10
|
+
output_buffer.prepend(path_hints.html_safe).concat('</div>'.html_safe)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
PartialRenderer.class_eval do
|
15
|
+
def render_partial
|
16
|
+
PathHints.apply(@view, @template, _render_partial)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# If there's a way to call super instead of copypasta let me know.
|
22
|
+
# pulled from actionview-5.1.6/lib/action_view/renderer/partial_renderer.rb:330
|
23
|
+
def _render_partial
|
24
|
+
instrument(:partial) do |payload|
|
25
|
+
view, locals, block = @view, @locals, @block
|
26
|
+
object, as = @object, @variable
|
27
|
+
|
28
|
+
if !block && (layout = @options[:layout])
|
29
|
+
layout = find_template(layout.to_s, @template_keys)
|
30
|
+
end
|
31
|
+
|
32
|
+
object = locals[as] if object.nil? # Respect object when object is false
|
33
|
+
locals[as] = object if @has_object
|
34
|
+
|
35
|
+
content = @template.render(view, locals) do |*name|
|
36
|
+
view._layout_for(*name, &block)
|
37
|
+
end
|
38
|
+
|
39
|
+
content = layout.render(view, locals) { content } if layout
|
40
|
+
payload[:cache_hit] = view.view_renderer.cache_hits[@template.virtual_path]
|
41
|
+
content
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: actionview-path_hints
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Tulino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Path hints for partials
|
14
|
+
email: rtulino@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/action_view/path_hints.rb
|
20
|
+
homepage: http://rubygems.org/gems/actionview-path_hints
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.11
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Path hints
|
44
|
+
test_files: []
|