floatable-rails 0.1.3 → 0.1.4
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/CHANGELOG.md +4 -0
- data/lib/floatable/rails/slim_view_instrumentation.rb +22 -25
- data/lib/floatable/rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9288ca577a553f70abaa3928fe8dd0ac842f080a3ac4408e478fcac5c2d27c2f
|
|
4
|
+
data.tar.gz: 2947208f0c7d70d327da7ddd8d89504c92526bc142240c82ce8409af85902d63
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 158ba1e2e4b3d4a17891907c5cd5af51b428707add8b9d42950dea39d897689961b07e5d02f290bcef9ded34cf8587d99bf3f4e095367ba37151f5bf4088cfee
|
|
7
|
+
data.tar.gz: 746df7f292f50792d22366625b04d60e5a9ba5c09335a3bd0f68f6fc421d84ce81bf6bec8369c6924ca9e472e1e735de34cac12ea0f02fac12416ee5370b2a9a
|
data/CHANGELOG.md
CHANGED
|
@@ -10,42 +10,39 @@ module Floatable
|
|
|
10
10
|
|
|
11
11
|
first_non_empty = lines.index { |l| !l.strip.empty? } || 0
|
|
12
12
|
|
|
13
|
-
# Keep optional Slim headers (doctype
|
|
14
|
-
doctype_idx =
|
|
15
|
-
first_non_empty
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
html_idx = nil
|
|
19
|
-
if doctype_idx
|
|
20
|
-
rel = lines[(doctype_idx + 1)..].to_a.index { |l| !l.strip.empty? && l.lstrip.match?(/\Ahtml\b/) }
|
|
21
|
-
html_idx = rel ? (doctype_idx + 1 + rel) : nil
|
|
22
|
-
end
|
|
13
|
+
# Keep optional Slim headers (doctype) at the very top if present.
|
|
14
|
+
doctype_idx =
|
|
15
|
+
if lines[first_non_empty]&.lstrip&.match?(/\A(doctype\b|!!!\b)/)
|
|
16
|
+
first_non_empty
|
|
17
|
+
end
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
# Insert before the first real line to avoid nesting inside blocks.
|
|
20
|
+
insert_at = doctype_idx ? (doctype_idx + 1) : first_non_empty
|
|
21
|
+
insert_at = [ insert_at, lines.length ].min
|
|
26
22
|
|
|
27
|
-
# Choose indentation that won't break Slim parsing.
|
|
28
23
|
marker_indent =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else
|
|
34
|
-
base_line = lines[insert_after] || ""
|
|
35
|
-
(base_line[/\A[ \t]*/] || "") + " "
|
|
36
|
-
end
|
|
24
|
+
if insert_at < lines.length
|
|
25
|
+
lines[insert_at].to_s[/\A[ \t]*/] || ""
|
|
26
|
+
else
|
|
27
|
+
lines[first_non_empty].to_s[/\A[ \t]*/] || ""
|
|
37
28
|
end
|
|
38
29
|
|
|
39
|
-
begin_marker =
|
|
40
|
-
|
|
30
|
+
begin_marker = [
|
|
31
|
+
"#{marker_indent}- (@output_buffer.safe_concat('<!-- #{::Floatable::Rails::VIEW_COMMENT_BEGIN} #{view_path} -->') if Thread.current[:floatable_enabled] && defined?(@output_buffer)); nil"
|
|
32
|
+
]
|
|
33
|
+
end_marker = [
|
|
34
|
+
"#{marker_indent}- (@output_buffer.safe_concat('<!-- #{::Floatable::Rails::VIEW_COMMENT_END} #{view_path} -->') if Thread.current[:floatable_enabled] && defined?(@output_buffer)); nil"
|
|
35
|
+
]
|
|
41
36
|
|
|
42
37
|
out = []
|
|
43
38
|
lines.each_with_index do |line, idx|
|
|
39
|
+
out.concat(begin_marker) if idx == insert_at
|
|
44
40
|
out << line
|
|
45
|
-
out << begin_marker if idx == insert_after
|
|
46
41
|
end
|
|
47
42
|
|
|
48
|
-
out
|
|
43
|
+
out.concat(begin_marker) if insert_at == lines.length
|
|
44
|
+
|
|
45
|
+
out.concat(end_marker)
|
|
49
46
|
out.join("\n")
|
|
50
47
|
end
|
|
51
48
|
end
|