hiccdown 1.0.2 → 1.1.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 +4 -4
- data/lib/hiccdown/railtie.rb +54 -0
- data/lib/hiccdown.rb +8 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec47ca144d66143fcbaeb25565e8b532f16360d945e71f2ecbd8d674f02ee87
|
4
|
+
data.tar.gz: e41233aabc2c40c32ead95ad5094ff54a770363e5f9633d59c8cea1edee18685
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3de717f3a9fb3224fd9ea8ae7591e777e66806a3e138eedad7fe4b30fc1a29ae5dd4a1d2de49f8661041c812b6565a7e8fa4d2640ead78a31ae510f7d490bf6
|
7
|
+
data.tar.gz: aaad7df8e3d58cb6e2fe095bdece16b4535db41b6def44c5d8b81fd6f28c26d68c0ac15c49cc9c18fe8232208d255adcf4eebc3115915a27b0f13742cb07890d
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Hiccdown
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
initializer 'hiccdown.action_controller' do
|
4
|
+
ActiveSupport.on_load(:action_controller) do
|
5
|
+
include CustomViewRendering
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module CustomViewRendering
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
alias_method :original_render, :render
|
15
|
+
alias_method :original_default_render, :default_render
|
16
|
+
alias_method :render, :custom_render
|
17
|
+
alias_method :default_render, :custom_default_render
|
18
|
+
end
|
19
|
+
|
20
|
+
def custom_render *args
|
21
|
+
options = args.extract_options!
|
22
|
+
|
23
|
+
# Implicit rendering
|
24
|
+
if options.empty? && args.empty?
|
25
|
+
custom_default_render
|
26
|
+
# Explicit rendering, such as `render :show` or `render action: :show`,
|
27
|
+
# but not partials or files (which would include a /)
|
28
|
+
elsif options.key?(:action) || args.first.is_a?(Symbol) || (args.first.is_a?(String) && !args.first.include?('/'))
|
29
|
+
action_name = options[:action] || args.first.to_s
|
30
|
+
render_helper_method(action_name, options)
|
31
|
+
# Partials, files and all other cases
|
32
|
+
else
|
33
|
+
original_render(*args, options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def custom_default_render
|
38
|
+
render_helper_method(params[:action])
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def render_helper_method action_name, options = {}
|
44
|
+
helper_module = "#{self.class.name.gsub('Controller', '')}Helper".constantize
|
45
|
+
|
46
|
+
if helper_module.instance_methods(false).include?(action_name.to_sym)
|
47
|
+
content = helper_module.instance_method(action_name).bind(view_context).call
|
48
|
+
original_render({ html: Hiccdown::to_html(content).html_safe }.merge(options))
|
49
|
+
else
|
50
|
+
original_render({ action: action_name }.merge(options))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/hiccdown.rb
CHANGED
@@ -8,6 +8,10 @@ module Hiccdown
|
|
8
8
|
base.prepend(MethodOverrides)
|
9
9
|
end
|
10
10
|
|
11
|
+
def scope *args, &block
|
12
|
+
Hiccdown::scope(*args, &block)
|
13
|
+
end
|
14
|
+
|
11
15
|
module MethodOverrides
|
12
16
|
def self.prepended(base)
|
13
17
|
# button_to and link_to use content_tag internally so need no explicit mention.
|
@@ -29,6 +33,10 @@ module Hiccdown
|
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
36
|
+
def self.scope *args, &block
|
37
|
+
block.call(*args)
|
38
|
+
end
|
39
|
+
|
32
40
|
def self.standalone_tags
|
33
41
|
Set.new([:area, :base, :br, :col, :command, :embed, :hr, :img, :input, :keygen, :link, :menuitem, :meta, :param, :source, :track, :wbr])
|
34
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiccdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Hackethal
|
@@ -17,6 +17,7 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/hiccdown.rb
|
20
|
+
- lib/hiccdown/railtie.rb
|
20
21
|
homepage: https://github.com/dchacke/hiccdown
|
21
22
|
licenses:
|
22
23
|
- MIT
|