heartml 1.0.0.beta4 → 1.0.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +3 -1
- data/lib/heartml/fragment.rb +2 -2
- data/lib/heartml/version.rb +1 -1
- data/lib/heartml.rb +16 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 053e789d42574715a2f4269205a6dfe549a3d4af6970a6f6446b51735a9be340
|
4
|
+
data.tar.gz: cfe795359ca2e951218853f336057d4751bac7e04564bc857808573c3f2e045a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36c6248a2b135f2d11b20b054d2a6bf8334460d56fe184a6c4d646e92561c2210e1e3a707975930613ed86091812708888b14d1fbd46f5efefe3befe3aeb3558
|
7
|
+
data.tar.gz: a4241d8e092361148f6ce228c0023007c7e97e650ab4c4336ea12b1f61287f1c1b034eff06f97f6718ae1c400fb82f252197de9205bdd7057058ad382cb56ce6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.0.0.beta5] - 2023-09-04
|
4
|
+
|
5
|
+
- Fix issue with ViewComponent in Rails apps
|
6
|
+
- Add fragment error handling
|
7
|
+
|
3
8
|
## [1.0.0.beta4] - 2023-08-27
|
4
9
|
|
5
10
|
- Refactor and improve Bridgetown plugin and simplify context handling for template rendering
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
heartml (1.0.0.
|
4
|
+
heartml (1.0.0.beta5)
|
5
5
|
concurrent-ruby (~> 1.2)
|
6
6
|
nokolexbor (>= 0.4.2)
|
7
7
|
|
@@ -38,7 +38,9 @@ GEM
|
|
38
38
|
racc (~> 1.4)
|
39
39
|
nokogiri (1.14.2-x86_64-linux)
|
40
40
|
racc (~> 1.4)
|
41
|
+
nokolexbor (0.5.0)
|
41
42
|
nokolexbor (0.5.0-arm64-darwin)
|
43
|
+
nokolexbor (0.5.0-x86_64-linux)
|
42
44
|
parallel (1.22.1)
|
43
45
|
parser (3.2.2.0)
|
44
46
|
ast (~> 2.4.1)
|
data/lib/heartml/fragment.rb
CHANGED
@@ -38,7 +38,7 @@ module Heartml
|
|
38
38
|
|
39
39
|
params.each do |param|
|
40
40
|
new_key, v2 = param.split(":").map(&:strip)
|
41
|
-
v2
|
41
|
+
v2 ||= new_key
|
42
42
|
|
43
43
|
new_attrs[new_key] = @component.evaluate_attribute_expression(attr, v2)
|
44
44
|
end
|
@@ -82,7 +82,7 @@ module Heartml
|
|
82
82
|
break unless attribute_binding.method.(attribute: attr_node, node: node)
|
83
83
|
end
|
84
84
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
85
|
-
line_segments = [@component.class.heart_module, @component.
|
85
|
+
line_segments = [@component.class.heart_module, @component._line_number_of_node(attr_node)]
|
86
86
|
raise e.class, e.message.lines.first, [line_segments.join(":"), *e.backtrace]
|
87
87
|
end
|
88
88
|
end
|
data/lib/heartml/version.rb
CHANGED
data/lib/heartml.rb
CHANGED
@@ -54,9 +54,13 @@ module Heartml
|
|
54
54
|
klass.attribute_binding "server-unsafe-eval", :_server_replace_binding
|
55
55
|
|
56
56
|
# Don't stomp on a superclass's `content` method
|
57
|
-
|
57
|
+
has_content_method = begin
|
58
|
+
klass.instance_method(:content)
|
59
|
+
rescue NameError
|
60
|
+
false
|
61
|
+
end
|
58
62
|
|
59
|
-
klass.include ContentMethod
|
63
|
+
klass.include ContentMethod unless has_content_method
|
60
64
|
end
|
61
65
|
|
62
66
|
# Extends the component class
|
@@ -124,10 +128,8 @@ module Heartml
|
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
127
|
-
|
128
|
-
|
129
|
-
instance_variable_get(:@doc_html)[0..loc].count("\n") + 1
|
130
|
-
end
|
131
|
+
# @return [String]
|
132
|
+
def doc_html = @doc_html
|
131
133
|
|
132
134
|
def attribute_bindings = @attribute_bindings ||= []
|
133
135
|
|
@@ -175,6 +177,7 @@ module Heartml
|
|
175
177
|
# @param content [String, Nokolexbor::Element]
|
176
178
|
def render_element(attributes: self.attributes, content: self.content, context: self.context) # rubocop:disable Metrics
|
177
179
|
doc = self.class.doc.clone
|
180
|
+
@doc_html ||= self.class.doc_html # keep a spare copy for determining error line number
|
178
181
|
@_content = content
|
179
182
|
@context = context
|
180
183
|
|
@@ -305,7 +308,7 @@ module Heartml
|
|
305
308
|
_context_locals.keys.reverse_each do |name|
|
306
309
|
eval_code = "#{name} = _context_locals[\"#{name}\"];" + eval_code
|
307
310
|
end
|
308
|
-
instance_eval(eval_code, self.class.heart_module,
|
311
|
+
instance_eval(eval_code, self.class.heart_module, _line_number_of_node(attribute))
|
309
312
|
end
|
310
313
|
|
311
314
|
def class_list_for(obj)
|
@@ -320,6 +323,11 @@ module Heartml
|
|
320
323
|
end.join(" ")
|
321
324
|
end
|
322
325
|
|
326
|
+
def _line_number_of_node(node)
|
327
|
+
loc = node.source_location
|
328
|
+
instance_variable_get(:@doc_html)[0..loc].count("\n") + 1
|
329
|
+
end
|
330
|
+
|
323
331
|
def _context_nodes = @_context_nodes ||= []
|
324
332
|
|
325
333
|
def _context_locals = @_context_locals ||= {}
|
@@ -376,12 +384,8 @@ module Heartml
|
|
376
384
|
"eval"
|
377
385
|
end
|
378
386
|
|
379
|
-
def self.line_number_of_node(_node)
|
380
|
-
# FIXME: this should actually work!
|
381
|
-
0
|
382
|
-
end
|
383
|
-
|
384
387
|
def initialize(body:, context:) # rubocop:disable Lint/MissingSuper
|
388
|
+
@doc_html = body.is_a?(String) ? body : body.to_html
|
385
389
|
@body = body.is_a?(String) ? Nokolexbor::DocumentFragment.parse(body) : body
|
386
390
|
@context = context
|
387
391
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heartml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|