partioprint 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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/partioprint.rb +64 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a95b6d74a14f5d1063052f9c921a5979e164788e
4
+ data.tar.gz: 8241e26bcee5562cd55058b905a690dfb759385b
5
+ SHA512:
6
+ metadata.gz: 22df7a1015c5dd2acece66c50883f4f27f7bd0907a32cbc352044fbd2f79878789d90d5e2313ec015d8a2aa41a6b79ffc1fa1f161fc677a5a14d010b0c579700
7
+ data.tar.gz: 0abf55751262a36b2de034c0d492a35cc9125cbcfddf909c18b141e501ae7eee82b37e33841b438665f9bbe0e89abc7aaa7729facd82177a7cb23e7f0bb0e5a7
@@ -0,0 +1,64 @@
1
+ class Partioprint
2
+ # Does nothing here
3
+ end
4
+
5
+ # Reopening PartialRenderer class
6
+ class ActionView::PartialRenderer
7
+ def render(context, options, block)
8
+ setup(context, options, block)
9
+ @template = find_partial
10
+
11
+ @lookup_context.rendered_format ||= begin
12
+ if @template && @template.formats.present?
13
+ @template.formats.first
14
+ else
15
+ formats.first
16
+ end
17
+ end
18
+ if @collection
19
+ render_collection
20
+ else
21
+ render_partial
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def render_partial
28
+ instrument(:partial) do |payload|
29
+ view, locals, block = @view, @locals, @block
30
+ object, as = @object, @variable
31
+
32
+ if !block && (layout = @options[:layout])
33
+ layout = find_template(layout.to_s, @template_keys)
34
+ end
35
+
36
+ object = locals[as] if object.nil? # Respect object when object is false
37
+ locals[as] = object if @has_object
38
+
39
+ content = @template.render(view, locals) do |*name|
40
+ view._layout_for(*name, &block)
41
+ end
42
+
43
+ partial_path = payload[:identifier].gsub(Rails.root.to_path, "")
44
+ content = add_comment_to_content(content, partial_path)
45
+
46
+ content = layout.render(view, locals) { content } if layout
47
+
48
+ payload[:cache_hit] = view.cache_hit
49
+ content
50
+ end
51
+ end
52
+
53
+ def add_comment_to_content(content, partial_path)
54
+ buffer("\n<!-- ERB:START partial '") +
55
+ buffer(partial_path) +
56
+ buffer("' -->\n") + content +
57
+ buffer("\n<!-- ERB:END partial '") + buffer(partial_path) +
58
+ buffer("' -->\n")
59
+ end
60
+
61
+ def buffer(str)
62
+ ActionView::OutputBuffer.new(str)
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: partioprint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Anil Wadghule
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem to add name of partial as comments in rendered HTML
14
+ email: anildigital@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/partioprint.rb
20
+ homepage: http://rubygems.org/gems/partioprint
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.5.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Partioprint
44
+ test_files: []