phlex-rails 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +2 -1
- data/config.ru +9 -0
- data/lib/generators/phlex/controller/templates/view.rb.erb +0 -2
- data/lib/generators/phlex/layout/templates/layout.rb.erb +0 -1
- data/lib/generators/phlex/page/templates/page.rb.erb +0 -2
- data/lib/install/phlex.rb +0 -12
- data/lib/phlex/rails/helpers.rb +27 -18
- data/lib/phlex/rails/layout.rb +1 -0
- data/lib/phlex/rails/renderable.rb +34 -2
- data/lib/phlex/rails/version.rb +1 -1
- data/lib/phlex/rails.rb +11 -0
- metadata +6 -39
- data/config/sus.rb +0 -5
- data/fixtures/dummy/app/assets/config/manifest.js +0 -0
- data/fixtures/dummy/app/components/comment_component.html.erb +0 -14
- data/fixtures/dummy/app/components/comment_component.rb +0 -8
- data/fixtures/dummy/app/components/reaction_component.html.erb +0 -3
- data/fixtures/dummy/app/components/reaction_component.rb +0 -7
- data/fixtures/dummy/app/controllers/articles_controller.rb +0 -4
- data/fixtures/dummy/app/controllers/comments_controller.rb +0 -4
- data/fixtures/dummy/app/views/application_view.rb +0 -7
- data/fixtures/dummy/app/views/articles/blog.html.erb +0 -14
- data/fixtures/dummy/app/views/articles/form.rb +0 -15
- data/fixtures/dummy/app/views/articles/index.html.erb +0 -14
- data/fixtures/dummy/app/views/articles/new.html.erb +0 -1
- data/fixtures/dummy/app/views/blog.rb +0 -27
- data/fixtures/dummy/app/views/card.rb +0 -15
- data/fixtures/dummy/app/views/comments/comment.rb +0 -25
- data/fixtures/dummy/app/views/comments/index.html.erb +0 -3
- data/fixtures/dummy/app/views/comments/reaction.rb +0 -17
- data/fixtures/dummy/app/views/comments/show.html.erb +0 -3
- data/fixtures/dummy/app/views/heading.rb +0 -9
- data/fixtures/dummy/config/database.yml +0 -3
- data/fixtures/dummy/config/routes.rb +0 -5
- data/fixtures/dummy/config/storage.yml +0 -3
- data/fixtures/dummy/db/schema.rb +0 -6
- data/fixtures/dummy/log/.gitignore +0 -1
- data/fixtures/dummy/public/favicon.ico +0 -0
- data/fixtures/rails_helper.rb +0 -9
- data/fixtures/view_helper.rb +0 -16
- data/lib/generators/phlex/collection/USAGE +0 -8
- data/lib/generators/phlex/collection/collection_generator.rb +0 -13
- data/lib/generators/phlex/collection/templates/collection.rb.erb +0 -16
- data/lib/generators/phlex/table/USAGE +0 -8
- data/lib/generators/phlex/table/table_generator.rb +0 -14
- data/lib/generators/phlex/table/templates/table.rb.erb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7235a9f512ec98cba7ac0c7b433c6b8862a79393d7759283f9374c2de12cbc30
|
4
|
+
data.tar.gz: 63090c17e5a2996f2dce0da406fb97a3e58a43bfdc7799120cef331f3eea5133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f6488be48a2585d14065193a5c15b8c96218926f1617ece544062fc2d6957a4ab0a43f4d9a46ce610ff5c2cc883c40547af9764699444976755df67784dc55f
|
7
|
+
data.tar.gz: 1154d9f20816c76a233b4d83e919189a7c020fa0b7e364c113ab496867b40d33e19d6516571c7237baa11ce96de78bbcbcc2522f4acc614e8d6122f1227dfc9b
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -6,8 +6,9 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
gem "phlex", github: "joeldrapper/phlex", branch: "main"
|
9
|
-
gem "
|
9
|
+
gem "rspec-rails"
|
10
10
|
gem "combustion"
|
11
11
|
gem "rubocop"
|
12
12
|
gem "solargraph"
|
13
|
+
gem "view_component"
|
13
14
|
gem "appraisal", github: "excid3/appraisal", branch: "fix-bundle-env"
|
data/config.ru
ADDED
@@ -1,8 +1,6 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
2
|
module Views
|
3
3
|
class <%= class_name %>::<%= @action.camelize %> < Phlex::HTML
|
4
|
-
include ApplicationView
|
5
|
-
|
6
4
|
def template
|
7
5
|
<%= "# " unless @has_layout %>render Layout.new(title: "<%= class_name.gsub("::", " ").titlecase %> - <%= @action.titlecase %>") do
|
8
6
|
h1 { "<%= class_name %>#<%= @action %>" }
|
data/lib/install/phlex.rb
CHANGED
@@ -15,18 +15,6 @@ unless application_configuration_content.match?(pattern)
|
|
15
15
|
)
|
16
16
|
end
|
17
17
|
|
18
|
-
unless Rails.root.join("app/views/application_view.rb").exist?
|
19
|
-
create_file(Rails.root.join("app/views/application_view.rb"), <<~RUBY)
|
20
|
-
# frozen_string_literal: true
|
21
|
-
|
22
|
-
module Views
|
23
|
-
module ApplicationView
|
24
|
-
include Rails.application.routes.url_helpers
|
25
|
-
end
|
26
|
-
end
|
27
|
-
RUBY
|
28
|
-
end
|
29
|
-
|
30
18
|
tailwind_config_path = Rails.root.join("config/tailwind.config.js")
|
31
19
|
|
32
20
|
if tailwind_config_path.exist?
|
data/lib/phlex/rails/helpers.rb
CHANGED
@@ -4,8 +4,8 @@ module Phlex
|
|
4
4
|
module Rails
|
5
5
|
module Helpers
|
6
6
|
module CSPMetaTag
|
7
|
-
def csp_meta_tag(
|
8
|
-
if (output = @_view_context.csp_meta_tag(
|
7
|
+
def csp_meta_tag(...)
|
8
|
+
if (output = @_view_context.csp_meta_tag(...))
|
9
9
|
@_target << output
|
10
10
|
end
|
11
11
|
end
|
@@ -63,6 +63,7 @@ module Phlex
|
|
63
63
|
alias_method :week_field, :__output_method__
|
64
64
|
alias_method :weekday_select, :__output_method__
|
65
65
|
alias_method :button, :__output_method__
|
66
|
+
alias_method :rich_text_area, :__output_method__
|
66
67
|
end
|
67
68
|
|
68
69
|
def form_with(*args, **kwargs, &block)
|
@@ -77,64 +78,72 @@ module Phlex
|
|
77
78
|
end
|
78
79
|
|
79
80
|
module StylesheetLinkTag
|
80
|
-
def stylesheet_link_tag(
|
81
|
-
if (output = @_view_context.stylesheet_link_tag(
|
81
|
+
def stylesheet_link_tag(...)
|
82
|
+
if (output = @_view_context.stylesheet_link_tag(...))
|
82
83
|
@_target << output
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
88
|
module FaviconLinkTag
|
88
|
-
def favicon_link_tag(
|
89
|
-
if (output = @_view_context.favicon_link_tag(
|
89
|
+
def favicon_link_tag(...)
|
90
|
+
if (output = @_view_context.favicon_link_tag(...))
|
90
91
|
@_target << output
|
91
92
|
end
|
92
93
|
end
|
93
94
|
end
|
94
95
|
|
95
96
|
module ImageTag
|
96
|
-
def image_tag(
|
97
|
-
if (output = @_view_context.image_tag(
|
97
|
+
def image_tag(...)
|
98
|
+
if (output = @_view_context.image_tag(...))
|
98
99
|
@_target << output
|
99
100
|
end
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
103
104
|
module AudioTag
|
104
|
-
def audio_tag(
|
105
|
-
if (output = @_view_context.audio_tag(
|
105
|
+
def audio_tag(...)
|
106
|
+
if (output = @_view_context.audio_tag(...))
|
106
107
|
@_target << output
|
107
108
|
end
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
112
|
module VideoTag
|
112
|
-
def video_tag(
|
113
|
-
if (output = @_view_context.video_tag(
|
113
|
+
def video_tag(...)
|
114
|
+
if (output = @_view_context.video_tag(...))
|
114
115
|
@_target << output
|
115
116
|
end
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
119
120
|
module PreloadLinkTag
|
120
|
-
def preload_link_tag(
|
121
|
-
if (output = @_view_context.preload_link_tag(
|
121
|
+
def preload_link_tag(...)
|
122
|
+
if (output = @_view_context.preload_link_tag(...))
|
122
123
|
@_target << output
|
123
124
|
end
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
128
|
module JavaScriptIncludeTag
|
128
|
-
def javascript_include_tag(
|
129
|
-
if (output = @_view_context.javascript_include_tag(
|
129
|
+
def javascript_include_tag(...)
|
130
|
+
if (output = @_view_context.javascript_include_tag(...))
|
130
131
|
@_target << output
|
131
132
|
end
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
135
136
|
module JavaScriptImportmapTags
|
136
|
-
def javascript_importmap_tags
|
137
|
-
if (output = @_view_context.javascript_importmap_tags)
|
137
|
+
def javascript_importmap_tags(...)
|
138
|
+
if (output = @_view_context.javascript_importmap_tags(...))
|
139
|
+
@_target << output
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
module JavaScriptImportModuleTag
|
145
|
+
def javascript_import_module_tag(...)
|
146
|
+
if (output = @_view_context.javascript_import_module_tag(...))
|
138
147
|
@_target << output
|
139
148
|
end
|
140
149
|
end
|
data/lib/phlex/rails/layout.rb
CHANGED
@@ -21,7 +21,15 @@ module Phlex
|
|
21
21
|
call(view_context: view_context) do |*args|
|
22
22
|
view_context.with_output_buffer(self) do
|
23
23
|
original_length = @_target.length
|
24
|
-
|
24
|
+
|
25
|
+
if args.length == 1 && Phlex::HTML === args[0]
|
26
|
+
output = yield(
|
27
|
+
args[0].unbuffered
|
28
|
+
)
|
29
|
+
else
|
30
|
+
output = yield(*args)
|
31
|
+
end
|
32
|
+
|
25
33
|
unchanged = (original_length == @_target.length)
|
26
34
|
|
27
35
|
if unchanged
|
@@ -32,6 +40,8 @@ module Phlex
|
|
32
40
|
end
|
33
41
|
end
|
34
42
|
end
|
43
|
+
|
44
|
+
nil
|
35
45
|
end.html_safe
|
36
46
|
else
|
37
47
|
call(view_context: view_context).html_safe
|
@@ -63,12 +73,34 @@ module Phlex
|
|
63
73
|
end
|
64
74
|
|
65
75
|
def capture
|
66
|
-
super
|
76
|
+
super&.html_safe
|
67
77
|
end
|
68
78
|
|
69
79
|
# Trick ViewComponent into thinking we're a ViewComponent to fix rendering output
|
70
80
|
def set_original_view_context(view_context)
|
71
81
|
end
|
82
|
+
|
83
|
+
private def yield_content(&block)
|
84
|
+
return unless block
|
85
|
+
|
86
|
+
case block.binding.receiver
|
87
|
+
when Phlex::HTML
|
88
|
+
super
|
89
|
+
else
|
90
|
+
@_view_context.with_output_buffer(self) { super }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
private def yield_content_with_args(*args, &block)
|
95
|
+
return unless block
|
96
|
+
|
97
|
+
case block.binding.receiver
|
98
|
+
when Phlex::HTML
|
99
|
+
super
|
100
|
+
else
|
101
|
+
@_view_context.with_output_buffer(self) { super }
|
102
|
+
end
|
103
|
+
end
|
72
104
|
end
|
73
105
|
end
|
74
106
|
end
|
data/lib/phlex/rails/version.rb
CHANGED
data/lib/phlex/rails.rb
CHANGED
@@ -10,5 +10,16 @@ module Phlex::Rails
|
|
10
10
|
loader.setup
|
11
11
|
end
|
12
12
|
|
13
|
+
module AppendMethodAddedWarning
|
14
|
+
def method_added(name)
|
15
|
+
if name == :append || name == :safe_append
|
16
|
+
raise Phlex::NameError, "You shouldn't redefine the #{name} method as it's required for safe HTML output."
|
17
|
+
end
|
18
|
+
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
13
23
|
Phlex::HTML.prepend(Phlex::Rails::Renderable)
|
24
|
+
Phlex::HTML.extend(Phlex::Rails::AppendMethodAddedWarning)
|
14
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phlex-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Drapper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.3.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.3.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2'
|
@@ -80,37 +80,7 @@ files:
|
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
82
82
|
- SECURITY.md
|
83
|
-
- config
|
84
|
-
- fixtures/dummy/app/assets/config/manifest.js
|
85
|
-
- fixtures/dummy/app/components/comment_component.html.erb
|
86
|
-
- fixtures/dummy/app/components/comment_component.rb
|
87
|
-
- fixtures/dummy/app/components/reaction_component.html.erb
|
88
|
-
- fixtures/dummy/app/components/reaction_component.rb
|
89
|
-
- fixtures/dummy/app/controllers/articles_controller.rb
|
90
|
-
- fixtures/dummy/app/controllers/comments_controller.rb
|
91
|
-
- fixtures/dummy/app/views/application_view.rb
|
92
|
-
- fixtures/dummy/app/views/articles/blog.html.erb
|
93
|
-
- fixtures/dummy/app/views/articles/form.rb
|
94
|
-
- fixtures/dummy/app/views/articles/index.html.erb
|
95
|
-
- fixtures/dummy/app/views/articles/new.html.erb
|
96
|
-
- fixtures/dummy/app/views/blog.rb
|
97
|
-
- fixtures/dummy/app/views/card.rb
|
98
|
-
- fixtures/dummy/app/views/comments/comment.rb
|
99
|
-
- fixtures/dummy/app/views/comments/index.html.erb
|
100
|
-
- fixtures/dummy/app/views/comments/reaction.rb
|
101
|
-
- fixtures/dummy/app/views/comments/show.html.erb
|
102
|
-
- fixtures/dummy/app/views/heading.rb
|
103
|
-
- fixtures/dummy/config/database.yml
|
104
|
-
- fixtures/dummy/config/routes.rb
|
105
|
-
- fixtures/dummy/config/storage.yml
|
106
|
-
- fixtures/dummy/db/schema.rb
|
107
|
-
- fixtures/dummy/log/.gitignore
|
108
|
-
- fixtures/dummy/public/favicon.ico
|
109
|
-
- fixtures/rails_helper.rb
|
110
|
-
- fixtures/view_helper.rb
|
111
|
-
- lib/generators/phlex/collection/USAGE
|
112
|
-
- lib/generators/phlex/collection/collection_generator.rb
|
113
|
-
- lib/generators/phlex/collection/templates/collection.rb.erb
|
83
|
+
- config.ru
|
114
84
|
- lib/generators/phlex/controller/USAGE
|
115
85
|
- lib/generators/phlex/controller/controller_generator.rb
|
116
86
|
- lib/generators/phlex/controller/templates/controller.rb.erb
|
@@ -121,9 +91,6 @@ files:
|
|
121
91
|
- lib/generators/phlex/page/USAGE
|
122
92
|
- lib/generators/phlex/page/page_generator.rb
|
123
93
|
- lib/generators/phlex/page/templates/page.rb.erb
|
124
|
-
- lib/generators/phlex/table/USAGE
|
125
|
-
- lib/generators/phlex/table/table_generator.rb
|
126
|
-
- lib/generators/phlex/table/templates/table.rb.erb
|
127
94
|
- lib/generators/phlex/view/USAGE
|
128
95
|
- lib/generators/phlex/view/templates/view.rb.erb
|
129
96
|
- lib/generators/phlex/view/view_generator.rb
|
@@ -167,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
134
|
- !ruby/object:Gem::Version
|
168
135
|
version: '0'
|
169
136
|
requirements: []
|
170
|
-
rubygems_version: 3.3
|
137
|
+
rubygems_version: 3.4.3
|
171
138
|
signing_key:
|
172
139
|
specification_version: 4
|
173
140
|
summary: A Phlex adapter for Rails
|
data/config/sus.rb
DELETED
File without changes
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<div>
|
2
|
-
<span>
|
3
|
-
<%= @name %>
|
4
|
-
</span>
|
5
|
-
<span>
|
6
|
-
<%= @body %>
|
7
|
-
</span>
|
8
|
-
|
9
|
-
<%= content %>
|
10
|
-
|
11
|
-
<%= render Views::Comments::Reaction.new(emoji: 'hamburger') do |reaction| %>
|
12
|
-
<p>Emoji reaction for a comment from <%= @name %> with body <%= @body %></p>
|
13
|
-
<% end %>
|
14
|
-
</div>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<%= render Views::Blog.new do |v| %>
|
2
|
-
|
3
|
-
hidden
|
4
|
-
|
5
|
-
<% v.with_post do %><%= link_to "First Post", "/posts/1" %><% end %>
|
6
|
-
|
7
|
-
content
|
8
|
-
|
9
|
-
<% v.with_header do %><%= link_to "My blog", "/" %><% end %>
|
10
|
-
|
11
|
-
here
|
12
|
-
|
13
|
-
<% v.with_post do %><%= link_to "Last Post", "/posts/2" %><% end %>
|
14
|
-
<% end %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<p>Before</p>
|
2
|
-
|
3
|
-
<%= render(Views::Heading.new) { "Hello World!" } %>
|
4
|
-
|
5
|
-
<%= render Views::Card.new do |a| %>
|
6
|
-
<p>Start Card A</p>
|
7
|
-
<%= a.title "Hello from A" %>
|
8
|
-
<%= render Views::Card.new do |b| %>
|
9
|
-
<p>Start Card B</p>
|
10
|
-
<%= b.title "Hello from B" %>
|
11
|
-
<p>End Card B</p>
|
12
|
-
<% end %>
|
13
|
-
<p>End Card A</p>
|
14
|
-
<% end %>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render Views::Articles::Form.new %>
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Views
|
4
|
-
class Blog < ApplicationView
|
5
|
-
def initialize
|
6
|
-
@posts = []
|
7
|
-
end
|
8
|
-
|
9
|
-
def template(&block)
|
10
|
-
capture(&block)
|
11
|
-
|
12
|
-
h3(class: "font-bold") { @header }
|
13
|
-
|
14
|
-
@posts.each do |post|
|
15
|
-
article(class: "drop-shadow p-5 rounded") { post }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def with_header(&block)
|
20
|
-
@header = capture(&block)
|
21
|
-
end
|
22
|
-
|
23
|
-
def with_post(&block)
|
24
|
-
@posts << capture(&block)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Views
|
4
|
-
module Comments
|
5
|
-
class Comment < ApplicationView
|
6
|
-
def initialize(name:, body:)
|
7
|
-
@name = name
|
8
|
-
@body = body
|
9
|
-
end
|
10
|
-
|
11
|
-
def template(&block)
|
12
|
-
div {
|
13
|
-
span { @name }
|
14
|
-
span { @body }
|
15
|
-
|
16
|
-
yield_content(&block)
|
17
|
-
|
18
|
-
render(::ReactionComponent.new(emoji: "hamburger")) do
|
19
|
-
p { "Emoji reaction for a comment from #{@name} with body #{@body}" }
|
20
|
-
end
|
21
|
-
}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/fixtures/dummy/db/schema.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
*.log
|
File without changes
|
data/fixtures/rails_helper.rb
DELETED
data/fixtures/view_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ViewHelper
|
4
|
-
def self.extended(parent)
|
5
|
-
parent.class_exec do
|
6
|
-
let(:output) { example.call }
|
7
|
-
let(:example) { view.new }
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def view(&block)
|
12
|
-
let :view do
|
13
|
-
Class.new(Phlex::HTML, &block)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
module Generators
|
5
|
-
class CollectionGenerator < ::Rails::Generators::NamedBase
|
6
|
-
source_root File.expand_path("templates", __dir__)
|
7
|
-
|
8
|
-
def create_view
|
9
|
-
template "collection.rb.erb", File.join("app/views", class_path, "#{file_name}.rb")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<% module_namespacing do -%>
|
2
|
-
module Views
|
3
|
-
class <%= class_name %> < Phlex::HTML
|
4
|
-
include ApplicationView
|
5
|
-
include Phlex::Collection
|
6
|
-
|
7
|
-
def collection_template(&)
|
8
|
-
ul(&)
|
9
|
-
end
|
10
|
-
|
11
|
-
def item_template
|
12
|
-
li { @item }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
<% end %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
module Generators
|
5
|
-
class TableGenerator < ::Rails::Generators::NamedBase
|
6
|
-
source_root File.expand_path("templates", __dir__)
|
7
|
-
class_option :properties, type: :array, default: []
|
8
|
-
|
9
|
-
def create_view
|
10
|
-
template "table.rb.erb", File.join("app/views", class_path, "#{file_name}.rb")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<% module_namespacing do -%>
|
2
|
-
module Views
|
3
|
-
class <%= class_name %> < Phlex::HTML
|
4
|
-
include ApplicationView
|
5
|
-
include Phlex::Table
|
6
|
-
|
7
|
-
<% options["properties"].each do |property| %>
|
8
|
-
property "<%= property.humanize %>", &:<%= property.underscore %><% end %>
|
9
|
-
end
|
10
|
-
end
|
11
|
-
<% end %>
|