reactionview 0.2.2 → 0.3.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/README.md +4 -1
- data/app/assets/javascripts/reactionview-dev-tools.esm.js +10 -3
- data/app/assets/javascripts/reactionview-dev-tools.esm.js.map +1 -1
- data/app/assets/javascripts/reactionview-dev-tools.umd.js +10 -3
- data/app/assets/javascripts/reactionview-dev-tools.umd.js.map +1 -1
- data/lib/generators/reactionview/install_generator.rb +3 -0
- data/lib/reactionview/config.rb +7 -0
- data/lib/reactionview/template/handlers/herb/herb.rb +16 -20
- data/lib/reactionview/template/handlers/herb.rb +20 -8
- data/lib/reactionview/version.rb +1 -1
- data/reactionview.gemspec +1 -1
- metadata +6 -6
|
@@ -23,6 +23,9 @@ module ReActionView
|
|
|
23
23
|
# Enable debug mode in development (adds debug attributes to HTML)
|
|
24
24
|
config.debug_mode = Rails.env.development?
|
|
25
25
|
|
|
26
|
+
# Validation mode (:raise, :overlay, or :none) — defaults to :raise in test, :overlay otherwise
|
|
27
|
+
# config.validation_mode = :overlay
|
|
28
|
+
|
|
26
29
|
# Add custom transform visitors to process templates before compilation
|
|
27
30
|
# config.transform_visitors = [
|
|
28
31
|
# Herb::Visitor::new
|
data/lib/reactionview/config.rb
CHANGED
|
@@ -5,6 +5,7 @@ module ReActionView
|
|
|
5
5
|
attr_accessor :intercept_erb
|
|
6
6
|
attr_accessor :debug_mode
|
|
7
7
|
attr_accessor :transform_visitors
|
|
8
|
+
attr_writer :validation_mode
|
|
8
9
|
|
|
9
10
|
def initialize
|
|
10
11
|
@intercept_erb = false
|
|
@@ -12,6 +13,12 @@ module ReActionView
|
|
|
12
13
|
@transform_visitors = []
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
def validation_mode
|
|
17
|
+
return @validation_mode unless @validation_mode.nil?
|
|
18
|
+
|
|
19
|
+
test? ? :raise : :overlay
|
|
20
|
+
end
|
|
21
|
+
|
|
15
22
|
def development?
|
|
16
23
|
defined?(Rails) && Rails.env.development?
|
|
17
24
|
end
|
|
@@ -22,9 +22,9 @@ module ReActionView
|
|
|
22
22
|
|
|
23
23
|
# Disable all Herb escape functions - let ActionView::OutputBuffer handle escaping
|
|
24
24
|
properties[:escapefunc] = ""
|
|
25
|
-
properties[:attrfunc] =
|
|
26
|
-
properties[:jsfunc] =
|
|
27
|
-
properties[:cssfunc] =
|
|
25
|
+
properties[:attrfunc] = nil
|
|
26
|
+
properties[:jsfunc] = nil
|
|
27
|
+
properties[:cssfunc] = nil
|
|
28
28
|
|
|
29
29
|
super
|
|
30
30
|
end
|
|
@@ -48,31 +48,27 @@ module ReActionView
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def add_expression(indicator, code)
|
|
51
|
-
add_rails_expression(indicator, code, wrap_parentheses: true)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def add_expression_block(indicator, code)
|
|
55
|
-
add_rails_expression(indicator, code, wrap_parentheses: false)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def add_rails_expression(indicator, code, wrap_parentheses:)
|
|
59
51
|
flush_newline_if_pending(@src)
|
|
60
52
|
|
|
61
53
|
with_buffer do
|
|
62
|
-
@src <<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
".append="
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
if wrap_parentheses
|
|
69
|
-
@src << "(" << code << ")"
|
|
70
|
-
else
|
|
54
|
+
@src << expression_append_method(indicator)
|
|
55
|
+
|
|
56
|
+
if expression_block?
|
|
71
57
|
@src << " " << code
|
|
58
|
+
else
|
|
59
|
+
@src << "(" << code << trailing_newline(code) << ")"
|
|
72
60
|
end
|
|
73
61
|
end
|
|
74
62
|
end
|
|
75
63
|
|
|
64
|
+
def expression_append_method(indicator)
|
|
65
|
+
if (indicator == "==") || @escape
|
|
66
|
+
".safe_expr_append="
|
|
67
|
+
else
|
|
68
|
+
".append="
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
76
72
|
def add_code(code)
|
|
77
73
|
flush_newline_if_pending(@src)
|
|
78
74
|
super
|
|
@@ -21,7 +21,7 @@ module ReActionView
|
|
|
21
21
|
config = {
|
|
22
22
|
filename: template.identifier,
|
|
23
23
|
project_path: Rails.root.to_s,
|
|
24
|
-
validation_mode:
|
|
24
|
+
validation_mode: ReActionView.config.validation_mode,
|
|
25
25
|
content_for_head: reactionview_dev_tools_markup(template),
|
|
26
26
|
visitors: visitors + ReActionView.config.transform_visitors,
|
|
27
27
|
}
|
|
@@ -59,16 +59,28 @@ module ReActionView
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def reactionview_dev_tools_markup(template)
|
|
62
|
-
return nil unless layout_template?(template)
|
|
62
|
+
return nil unless layout_template?(template)
|
|
63
63
|
return nil unless local_template?(template)
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
<meta name="herb-debug-mode" content="true">
|
|
67
|
-
<meta name="herb-project-path" content="#{Rails.root}">
|
|
68
|
-
#{editor_meta_tag}
|
|
65
|
+
markup = +""
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
if ::ReActionView.config.debug_mode_enabled?
|
|
68
|
+
markup << <<~HTML
|
|
69
|
+
<meta name="herb-debug-mode" content="true">
|
|
70
|
+
<meta name="herb-project-path" content="#{Rails.root}">
|
|
71
|
+
#{editor_meta_tag}
|
|
72
|
+
|
|
73
|
+
#{ActionController::Base.new.view_context.javascript_include_tag "reactionview-dev-tools.umd.js", defer: true}
|
|
74
|
+
HTML
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if ::ReActionView.config.validation_mode == :overlay
|
|
78
|
+
markup << <<~HTML
|
|
79
|
+
<template data-herb-dismiss-hint>You can also disable this overlay by setting <code style="color: #ffeb3b; font-family: monospace; font-size: 12pt;">config.validation_mode = :none</code> in <code style="color: #ffeb3b; font-family: monospace; font-size: 12pt;">config/initializers/reactionview.rb</code>.</template>
|
|
80
|
+
HTML
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
markup.presence
|
|
72
84
|
end
|
|
73
85
|
end
|
|
74
86
|
end
|
data/lib/reactionview/version.rb
CHANGED
data/reactionview.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: reactionview
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-08-18 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: actionview
|
|
@@ -29,20 +29,20 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.9.0
|
|
33
33
|
- - "<"
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: 0.
|
|
35
|
+
version: 0.10.0
|
|
36
36
|
type: :runtime
|
|
37
37
|
prerelease: false
|
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
39
39
|
requirements:
|
|
40
40
|
- - ">="
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: 0.
|
|
42
|
+
version: 0.9.0
|
|
43
43
|
- - "<"
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 0.
|
|
45
|
+
version: 0.10.0
|
|
46
46
|
description: An ActionView-compatible ERB engine with modern DX - re-imagined with
|
|
47
47
|
Herb.
|
|
48
48
|
email:
|