ilex 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.versionrc.json +7 -7
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +4 -1
- data/lib/ilex.rb +1 -0
- data/lib/ilex/arbre_ext/element.rb +27 -27
- data/lib/ilex/arbre_ext/element/builder_methods.rb +20 -0
- data/lib/ilex/component.rb +49 -49
- data/lib/ilex/component_warden.rb +65 -65
- data/lib/ilex/component_wardens.rb +18 -18
- data/lib/ilex/context.rb +62 -62
- data/lib/ilex/engine.rb +10 -9
- data/lib/ilex/rails_ext/action_view/base.rb +21 -21
- data/lib/ilex/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1cef48991c440c63571d00490a85cfdd407e6b7c2efbdd560660948ed47bd57
|
4
|
+
data.tar.gz: 925406a78b7b417f82b979294b66254847a7d352cecf4e0ab9b739fdb82eefd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e56764de81c18320e29c3753c959ad146aca5b5ccdfc7aedb1c5ddbddaece23be2010b1c58b905332ca72597f9cec2b974910e009b93ed423bdd960b1ed787c
|
7
|
+
data.tar.gz: 6992772c2f5ac33665a01c182e11f4f3e7655f6d5cf9625c8c25fc7e7c11784922364e2849ab275ad7ed7c6031b867a461ff6f2eb61904c65129a1147c3170b9
|
data/.versionrc.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
{
|
2
|
-
"skip": {
|
3
|
-
"tag": true
|
4
|
-
},
|
5
|
-
"NAME": "Ilex",
|
6
|
-
"VERSION": "0.1.6"
|
7
|
-
}
|
1
|
+
{
|
2
|
+
"skip": {
|
3
|
+
"tag": true
|
4
|
+
},
|
5
|
+
"NAME": "Ilex",
|
6
|
+
"VERSION": "0.1.6"
|
7
|
+
}
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
4
4
|
|
5
|
+
### [0.1.7](https://github.com/joshleblanc/ilex/compare/v0.1.6...v0.1.7) (2021-06-16)
|
6
|
+
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
* try and convert component arrays into strings ([13e0438](https://github.com/joshleblanc/ilex/commit/13e0438d1da6ebd0bc0b46c9ca7cc6828bd99a7f))
|
11
|
+
|
5
12
|
### [0.1.6](https://github.com/joshleblanc/cedar/compare/v0.1.5...v0.1.6) (2021-04-18)
|
6
13
|
|
7
14
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ilex (0.1.
|
4
|
+
ilex (0.1.7)
|
5
5
|
arbre
|
6
6
|
rails (>= 5.2, < 7.0)
|
7
7
|
|
@@ -91,6 +91,8 @@ GEM
|
|
91
91
|
nio4r (2.5.7)
|
92
92
|
nokogiri (1.11.2-x64-mingw32)
|
93
93
|
racc (~> 1.4)
|
94
|
+
nokogiri (1.11.2-x86_64-linux)
|
95
|
+
racc (~> 1.4)
|
94
96
|
parallel (1.20.1)
|
95
97
|
parser (3.0.0.0)
|
96
98
|
ast (~> 2.4.1)
|
@@ -164,6 +166,7 @@ GEM
|
|
164
166
|
|
165
167
|
PLATFORMS
|
166
168
|
x64-mingw32
|
169
|
+
x86_64-linux
|
167
170
|
|
168
171
|
DEPENDENCIES
|
169
172
|
ilex!
|
data/lib/ilex.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative "ilex/component_wardens"
|
|
7
7
|
require_relative "ilex/context"
|
8
8
|
require_relative "ilex/component"
|
9
9
|
require_relative "ilex/arbre_ext/element"
|
10
|
+
require_relative "ilex/arbre_ext/element/builder_methods"
|
10
11
|
require_relative "ilex/rails_ext/action_view/base"
|
11
12
|
require_relative "ilex/engine"
|
12
13
|
|
@@ -1,27 +1,27 @@
|
|
1
|
-
module Ilex
|
2
|
-
module ArbreExt
|
3
|
-
module Element
|
4
|
-
ruby2_keywords def method_missing(name, *args, &block)
|
5
|
-
if current_arbre_element.respond_to?(name)
|
6
|
-
current_arbre_element.send name, *args, &block
|
7
|
-
elsif assigns && assigns.has_key?(name)
|
8
|
-
assigns[name]
|
9
|
-
elsif helpers.respond_to?(name)
|
10
|
-
helper_capture(name, *args, &block)
|
11
|
-
else
|
12
|
-
super
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# The helper might have a block that builds Arbre elements
|
17
|
-
# which will be rendered (#to_s) inside ActionView::Base#capture.
|
18
|
-
# We do not want such elements added to self, so we push a dummy
|
19
|
-
# current_arbre_element.
|
20
|
-
def helper_capture(name, *args, &block)
|
21
|
-
s = ""
|
22
|
-
within(Element.new) { s = helpers.send(name, *args, &block) }
|
23
|
-
s.is_a?(Element) ? s.to_s : s
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
module Ilex
|
2
|
+
module ArbreExt
|
3
|
+
module Element
|
4
|
+
ruby2_keywords def method_missing(name, *args, &block)
|
5
|
+
if current_arbre_element.respond_to?(name)
|
6
|
+
current_arbre_element.send name, *args, &block
|
7
|
+
elsif assigns && assigns.has_key?(name)
|
8
|
+
assigns[name]
|
9
|
+
elsif helpers.respond_to?(name)
|
10
|
+
helper_capture(name, *args, &block)
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# The helper might have a block that builds Arbre elements
|
17
|
+
# which will be rendered (#to_s) inside ActionView::Base#capture.
|
18
|
+
# We do not want such elements added to self, so we push a dummy
|
19
|
+
# current_arbre_element.
|
20
|
+
def helper_capture(name, *args, &block)
|
21
|
+
s = ""
|
22
|
+
within(Element.new) { s = helpers.send(name, *args, &block) }
|
23
|
+
s.is_a?(Element) ? s.to_s : s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ilex
|
2
|
+
module ArbreExt
|
3
|
+
module Element
|
4
|
+
module BuilderMethods
|
5
|
+
private
|
6
|
+
|
7
|
+
def append_return_block(tag)
|
8
|
+
return nil if current_arbre_element.children?
|
9
|
+
return unless appendable_tag?(tag)
|
10
|
+
|
11
|
+
current_arbre_element << if tag.is_a? Array
|
12
|
+
Arbre::HTML::TextNode.from_string(tag.join.html_safe)
|
13
|
+
else
|
14
|
+
Arbre::HTML::TextNode.from_string(tag.to_s)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/ilex/component.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ilex
|
4
|
-
|
5
|
-
##
|
6
|
-
# InlineRender provides a `render` dsl to your components
|
7
|
-
# which will render any arbre tree within.
|
8
|
-
#
|
9
|
-
# It will also convert snake case component names to component instances
|
10
|
-
# for example, this would be equivalent to `ButtonComponent.new(label: "Test")`
|
11
|
-
#
|
12
|
-
# ```ruby
|
13
|
-
# render do
|
14
|
-
# div do
|
15
|
-
# button label: "Test"
|
16
|
-
# end
|
17
|
-
# end
|
18
|
-
# ```
|
19
|
-
module Component
|
20
|
-
include Arbre::HTML
|
21
|
-
|
22
|
-
def render(*args, &blk)
|
23
|
-
define_method :call do
|
24
|
-
ctx = Context.new(self)
|
25
|
-
ctx.instance_eval(&blk).to_s
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def find_component(name, base_module = nil)
|
30
|
-
target = if base_module
|
31
|
-
base_module
|
32
|
-
else
|
33
|
-
self
|
34
|
-
end
|
35
|
-
|
36
|
-
if target.const_defined?(name)
|
37
|
-
target.const_get(name)
|
38
|
-
else
|
39
|
-
if target.superclass.respond_to?(:find_component)
|
40
|
-
target.superclass.find_component(name)
|
41
|
-
else
|
42
|
-
adjusted_name = name.chomp("Component").underscore
|
43
|
-
raise(NameError, "undefined local variable or method `#{adjusted_name}` for #{self}")
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ilex
|
4
|
+
|
5
|
+
##
|
6
|
+
# InlineRender provides a `render` dsl to your components
|
7
|
+
# which will render any arbre tree within.
|
8
|
+
#
|
9
|
+
# It will also convert snake case component names to component instances
|
10
|
+
# for example, this would be equivalent to `ButtonComponent.new(label: "Test")`
|
11
|
+
#
|
12
|
+
# ```ruby
|
13
|
+
# render do
|
14
|
+
# div do
|
15
|
+
# button label: "Test"
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# ```
|
19
|
+
module Component
|
20
|
+
include Arbre::HTML
|
21
|
+
|
22
|
+
def render(*args, &blk)
|
23
|
+
define_method :call do
|
24
|
+
ctx = Context.new(self)
|
25
|
+
ctx.instance_eval(&blk).to_s
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_component(name, base_module = nil)
|
30
|
+
target = if base_module
|
31
|
+
base_module
|
32
|
+
else
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
if target.const_defined?(name)
|
37
|
+
target.const_get(name)
|
38
|
+
else
|
39
|
+
if target.superclass.respond_to?(:find_component)
|
40
|
+
target.superclass.find_component(name)
|
41
|
+
else
|
42
|
+
adjusted_name = name.chomp("Component").underscore
|
43
|
+
raise(NameError, "undefined local variable or method `#{adjusted_name}` for #{self}")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,65 +1,65 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ilex
|
4
|
-
##
|
5
|
-
# A ComponentWarden is responsible for locating potential components
|
6
|
-
# given a snake_case representation of that component.
|
7
|
-
#
|
8
|
-
# If a component exists, the warden is also responsible for calling the correct
|
9
|
-
# instantiation method, depending if the component is a collection or not
|
10
|
-
class ComponentWarden
|
11
|
-
def initialize(component, string)
|
12
|
-
@component = component
|
13
|
-
@input = string.to_s
|
14
|
-
|
15
|
-
@collection = @input.end_with? "_collection"
|
16
|
-
@nested = @input.include? "__"
|
17
|
-
|
18
|
-
process_input!(@input)
|
19
|
-
end
|
20
|
-
|
21
|
-
def collection?
|
22
|
-
@collection
|
23
|
-
end
|
24
|
-
|
25
|
-
def nested?
|
26
|
-
@nested
|
27
|
-
end
|
28
|
-
|
29
|
-
def component_name
|
30
|
-
"#{@input}_component".camelize
|
31
|
-
end
|
32
|
-
|
33
|
-
def component_class
|
34
|
-
@component_class ||= @component.class.find_component(component_name, @base_module)
|
35
|
-
end
|
36
|
-
|
37
|
-
def exists?
|
38
|
-
component_class.present?
|
39
|
-
end
|
40
|
-
|
41
|
-
def new(*args, &block)
|
42
|
-
return nil unless exists?
|
43
|
-
|
44
|
-
if collection?
|
45
|
-
component_class.with_collection(*args)
|
46
|
-
else
|
47
|
-
component_class.new(*args)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def process_input!(input)
|
54
|
-
@input.chomp! "_collection"
|
55
|
-
@input.chomp! "_component"
|
56
|
-
|
57
|
-
if nested?
|
58
|
-
parts = @input.split("__")
|
59
|
-
@input = parts.pop
|
60
|
-
|
61
|
-
@base_module = parts.map(&:camelize).join("::").constantize
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ilex
|
4
|
+
##
|
5
|
+
# A ComponentWarden is responsible for locating potential components
|
6
|
+
# given a snake_case representation of that component.
|
7
|
+
#
|
8
|
+
# If a component exists, the warden is also responsible for calling the correct
|
9
|
+
# instantiation method, depending if the component is a collection or not
|
10
|
+
class ComponentWarden
|
11
|
+
def initialize(component, string)
|
12
|
+
@component = component
|
13
|
+
@input = string.to_s
|
14
|
+
|
15
|
+
@collection = @input.end_with? "_collection"
|
16
|
+
@nested = @input.include? "__"
|
17
|
+
|
18
|
+
process_input!(@input)
|
19
|
+
end
|
20
|
+
|
21
|
+
def collection?
|
22
|
+
@collection
|
23
|
+
end
|
24
|
+
|
25
|
+
def nested?
|
26
|
+
@nested
|
27
|
+
end
|
28
|
+
|
29
|
+
def component_name
|
30
|
+
"#{@input}_component".camelize
|
31
|
+
end
|
32
|
+
|
33
|
+
def component_class
|
34
|
+
@component_class ||= @component.class.find_component(component_name, @base_module)
|
35
|
+
end
|
36
|
+
|
37
|
+
def exists?
|
38
|
+
component_class.present?
|
39
|
+
end
|
40
|
+
|
41
|
+
def new(*args, &block)
|
42
|
+
return nil unless exists?
|
43
|
+
|
44
|
+
if collection?
|
45
|
+
component_class.with_collection(*args)
|
46
|
+
else
|
47
|
+
component_class.new(*args)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def process_input!(input)
|
54
|
+
@input.chomp! "_collection"
|
55
|
+
@input.chomp! "_component"
|
56
|
+
|
57
|
+
if nested?
|
58
|
+
parts = @input.split("__")
|
59
|
+
@input = parts.pop
|
60
|
+
|
61
|
+
@base_module = parts.map(&:camelize).join("::").constantize
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ilex
|
4
|
-
##
|
5
|
-
# Thin wrapper around a hash of component wardens
|
6
|
-
# such that the default is always an instance of ComponentWarden
|
7
|
-
class ComponentWardens
|
8
|
-
def initialize(component)
|
9
|
-
@wardens = Hash.new do |hash, key|
|
10
|
-
hash[key] = ComponentWarden.new(component, key)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def [](key)
|
15
|
-
@wardens[key]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ilex
|
4
|
+
##
|
5
|
+
# Thin wrapper around a hash of component wardens
|
6
|
+
# such that the default is always an instance of ComponentWarden
|
7
|
+
class ComponentWardens
|
8
|
+
def initialize(component)
|
9
|
+
@wardens = Hash.new do |hash, key|
|
10
|
+
hash[key] = ComponentWarden.new(component, key)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def [](key)
|
15
|
+
@wardens[key]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/ilex/context.rb
CHANGED
@@ -1,62 +1,62 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ilex
|
4
|
-
##
|
5
|
-
# Inject a component's instance variables into arbre's default context
|
6
|
-
# as well as provide implicit handling of snake-cased component names as
|
7
|
-
# tags
|
8
|
-
class Context < Arbre::Context
|
9
|
-
|
10
|
-
def initialize(component, &blk)
|
11
|
-
@component = component
|
12
|
-
|
13
|
-
|
14
|
-
# Copy all of the instance variables from the component to the context,
|
15
|
-
# so we have access to them when rendering
|
16
|
-
@component.instance_variables.each do |iv|
|
17
|
-
instance_variable_set(iv, @component.instance_variable_get(iv))
|
18
|
-
end
|
19
|
-
|
20
|
-
super({}, component, &blk)
|
21
|
-
end
|
22
|
-
|
23
|
-
def content
|
24
|
-
@component.send :content
|
25
|
-
end
|
26
|
-
|
27
|
-
def component_wardens
|
28
|
-
@component_wardens ||= ComponentWardens.new(@component)
|
29
|
-
end
|
30
|
-
|
31
|
-
# This is overriding arbre::rails::rendering
|
32
|
-
# It performs the same actions, but returns html_safe on a passed block
|
33
|
-
#
|
34
|
-
# Not 100% sure this is needed, but view_components won't render their
|
35
|
-
# contents without it, when rendered in an arbre tree
|
36
|
-
def render(*args)
|
37
|
-
rendered = helpers.render(*args) do
|
38
|
-
yield.html_safe if block_given?
|
39
|
-
end
|
40
|
-
case rendered
|
41
|
-
when Arbre::Context
|
42
|
-
current_arbre_element.add_child rendered
|
43
|
-
else
|
44
|
-
text_node rendered
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def respond_to_missing?(method, include_all)
|
49
|
-
@component.respond_to?(method) || component_wardens[method].exists? || super
|
50
|
-
end
|
51
|
-
|
52
|
-
def method_missing(method, *args, &content_block)
|
53
|
-
if @component.respond_to?(method)
|
54
|
-
@component.send(method, *args, &content_block)
|
55
|
-
elsif component_wardens[method].exists?
|
56
|
-
render component_wardens[method].new(*args), &content_block
|
57
|
-
else
|
58
|
-
super
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ilex
|
4
|
+
##
|
5
|
+
# Inject a component's instance variables into arbre's default context
|
6
|
+
# as well as provide implicit handling of snake-cased component names as
|
7
|
+
# tags
|
8
|
+
class Context < Arbre::Context
|
9
|
+
|
10
|
+
def initialize(component, &blk)
|
11
|
+
@component = component
|
12
|
+
|
13
|
+
|
14
|
+
# Copy all of the instance variables from the component to the context,
|
15
|
+
# so we have access to them when rendering
|
16
|
+
@component.instance_variables.each do |iv|
|
17
|
+
instance_variable_set(iv, @component.instance_variable_get(iv))
|
18
|
+
end
|
19
|
+
|
20
|
+
super({}, component, &blk)
|
21
|
+
end
|
22
|
+
|
23
|
+
def content
|
24
|
+
@component.send :content
|
25
|
+
end
|
26
|
+
|
27
|
+
def component_wardens
|
28
|
+
@component_wardens ||= ComponentWardens.new(@component)
|
29
|
+
end
|
30
|
+
|
31
|
+
# This is overriding arbre::rails::rendering
|
32
|
+
# It performs the same actions, but returns html_safe on a passed block
|
33
|
+
#
|
34
|
+
# Not 100% sure this is needed, but view_components won't render their
|
35
|
+
# contents without it, when rendered in an arbre tree
|
36
|
+
def render(*args)
|
37
|
+
rendered = helpers.render(*args) do
|
38
|
+
yield.html_safe if block_given?
|
39
|
+
end
|
40
|
+
case rendered
|
41
|
+
when Arbre::Context
|
42
|
+
current_arbre_element.add_child rendered
|
43
|
+
else
|
44
|
+
text_node rendered
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def respond_to_missing?(method, include_all)
|
49
|
+
@component.respond_to?(method) || component_wardens[method].exists? || super
|
50
|
+
end
|
51
|
+
|
52
|
+
def method_missing(method, *args, &content_block)
|
53
|
+
if @component.respond_to?(method)
|
54
|
+
@component.send(method, *args, &content_block)
|
55
|
+
elsif component_wardens[method].exists?
|
56
|
+
render component_wardens[method].new(*args), &content_block
|
57
|
+
else
|
58
|
+
super
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/ilex/engine.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
module Ilex
|
2
|
-
class Engine < ::Rails::Engine
|
3
|
-
|
4
|
-
config.to_prepare do
|
5
|
-
ActionView::Base.prepend RailsExt::ActionView::Base
|
6
|
-
Arbre::Element.prepend ArbreExt::Element
|
7
|
-
|
8
|
-
|
9
|
-
end
|
1
|
+
module Ilex
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
|
4
|
+
config.to_prepare do
|
5
|
+
ActionView::Base.prepend RailsExt::ActionView::Base
|
6
|
+
Arbre::Element.prepend ArbreExt::Element
|
7
|
+
Arbre::Element::BuilderMethods.prepend ArbreExt::Element::BuilderMethods
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
module Ilex
|
2
|
-
module RailsExt
|
3
|
-
module ActionView
|
4
|
-
module Base
|
5
|
-
def capture(*args)
|
6
|
-
value = nil
|
7
|
-
buffer = with_output_buffer { value = yield(*args) }
|
8
|
-
|
9
|
-
# Override to handle Arbre elements inside helper blocks.
|
10
|
-
# See https://github.com/rails/rails/issues/17661
|
11
|
-
# and https://github.com/rails/rails/pull/18024#commitcomment-8975180
|
12
|
-
value = value.to_s if value.is_a?(Arbre::Element)
|
13
|
-
|
14
|
-
if (string = buffer.presence || value) && string.is_a?(String)
|
15
|
-
ERB::Util.html_escape string
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
module Ilex
|
2
|
+
module RailsExt
|
3
|
+
module ActionView
|
4
|
+
module Base
|
5
|
+
def capture(*args)
|
6
|
+
value = nil
|
7
|
+
buffer = with_output_buffer { value = yield(*args) }
|
8
|
+
|
9
|
+
# Override to handle Arbre elements inside helper blocks.
|
10
|
+
# See https://github.com/rails/rails/issues/17661
|
11
|
+
# and https://github.com/rails/rails/pull/18024#commitcomment-8975180
|
12
|
+
value = value.to_s if value.is_a?(Arbre::Element)
|
13
|
+
|
14
|
+
if (string = buffer.presence || value) && string.is_a?(String)
|
15
|
+
ERB::Util.html_escape string
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ilex/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ilex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua LeBlanc
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: arbre
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- cedar.gemspec
|
68
68
|
- lib/ilex.rb
|
69
69
|
- lib/ilex/arbre_ext/element.rb
|
70
|
+
- lib/ilex/arbre_ext/element/builder_methods.rb
|
70
71
|
- lib/ilex/component.rb
|
71
72
|
- lib/ilex/component_warden.rb
|
72
73
|
- lib/ilex/component_wardens.rb
|
@@ -82,7 +83,7 @@ metadata:
|
|
82
83
|
homepage_uri: https://github.com/joshleblanc/ilex
|
83
84
|
source_code_uri: https://github.com/joshleblanc/ilex
|
84
85
|
changelog_uri: https://github.com/joshleblanc/ilex
|
85
|
-
post_install_message:
|
86
|
+
post_install_message:
|
86
87
|
rdoc_options: []
|
87
88
|
require_paths:
|
88
89
|
- lib
|
@@ -97,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
98
|
- !ruby/object:Gem::Version
|
98
99
|
version: '0'
|
99
100
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
-
signing_key:
|
101
|
+
rubygems_version: 3.2.15
|
102
|
+
signing_key:
|
102
103
|
specification_version: 4
|
103
104
|
summary: Provides inline rendering to view components
|
104
105
|
test_files: []
|