painless_partials 0.1.0

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.
data/CHANGELOG ADDED
File without changes
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,3 @@
1
+ if Rails.env == 'development'
2
+ require 'template_render_overrider'
3
+ end
@@ -0,0 +1,43 @@
1
+ #
2
+ # TODO: test for ajax case
3
+ # create specs
4
+ # setup only for development env
5
+ #
6
+ class ActionView::Template
7
+ def render_with_map_wrap(*args, &block)
8
+ part_html = render_without_map_wrap(*args, &block)
9
+ res = if mime_type.nil? || mime_type === [Mime::HTML, Mime::XML]
10
+ template_file = Pathname.new(self.inspect)
11
+
12
+ # show internal paths relative from Rails.root
13
+ if template_file.to_s =~ /#{Rails.root.parent}.*/
14
+ # "parent" used for showing as relative extensions placed on same level with main app
15
+ template_file = template_file.relative_path_from Rails.root
16
+ else
17
+ if template_file.to_s =~ /\/app\/views\/(.*)/
18
+ resource_path, resource_name = Pathname.new($1).split
19
+ end
20
+ end
21
+
22
+ wrapped = []
23
+ wrapped << "<!-- TEMPLATE: #{template_file} -->"
24
+ # TODO: make this by ajax call
25
+ if resource_name
26
+ wrapped << <<OVERRIDE_TIP
27
+ <!--
28
+ For overriding this partial you may run from project (or engine/extension) dir:
29
+ $ mkdir -p app/views/#{resource_path} && cp -i #{template_file} app/views/#{resource_path}/#{resource_name}
30
+ NOTE: Please make sure that it is what you want before running. In common case it is.
31
+ -->
32
+ OVERRIDE_TIP
33
+ end
34
+ wrapped << part_html
35
+ wrapped << "<!-- END TEMPLATE: #{template_file} -->"
36
+ wrapped.join("\n");
37
+ else
38
+ part_html
39
+ end
40
+ res.html_safe
41
+ end
42
+ alias_method_chain :render, :map_wrap
43
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: painless_partials
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - x@ES
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-04 00:00:00 +03:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: |
22
+ In case when we need to override some partial which may be plased in some engine-gem
23
+ it may be painfull to findout which partial are rendered in certain place.
24
+
25
+ For this purposes created gem painless_partials. It aimed to:
26
+ :as-minimum: markup html/xml by comments with partial paths (done)
27
+ :as-maximum: provide service for partial coping from gem into main app (50% done)
28
+ or into some extension (site-theme and so on)
29
+
30
+ It is usefurl, for example, in development of application based on spree.
31
+
32
+ email: KEIvanov@gmail.com
33
+ executables: []
34
+
35
+ extensions: []
36
+
37
+ extra_rdoc_files: []
38
+
39
+ files:
40
+ - VERSION
41
+ - CHANGELOG
42
+ - lib/painless_partials.rb
43
+ - lib/template_render_overrider.rb
44
+ has_rdoc: true
45
+ homepage: https://github.com/x2es/painless_partials
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 1
60
+ - 8
61
+ - 7
62
+ version: 1.8.7
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements:
72
+ - none
73
+ rubyforge_project:
74
+ rubygems_version: 1.3.7
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Markups html/xml by comments with partial paths
78
+ test_files: []
79
+