phlex 0.5.3 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of phlex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +1 -20
- data/config/sus.rb +0 -5
- data/lib/phlex/buffered.rb +2 -0
- data/lib/phlex/collection.rb +2 -0
- data/lib/phlex/elements.rb +1 -5
- data/lib/phlex/experimental.rb +10 -0
- data/lib/phlex/helpers.rb +2 -0
- data/lib/phlex/html.rb +73 -86
- data/lib/phlex/table.rb +1 -0
- data/lib/phlex/turbo/frame.rb +2 -0
- data/lib/phlex/turbo/stream.rb +2 -0
- data/lib/phlex/version.rb +1 -1
- data/lib/phlex.rb +2 -19
- metadata +6 -166
- data/Procfile.dev +0 -3
- data/Rakefile +0 -8
- data/config.ru +0 -9
- data/docs/assets/application.css +0 -32
- data/docs/assets/logo.png +0 -0
- data/docs/build.rb +0 -30
- data/docs/components/callout.rb +0 -9
- data/docs/components/code_block.rb +0 -26
- data/docs/components/code_span.rb +0 -9
- data/docs/components/example.rb +0 -32
- data/docs/components/heading.rb +0 -9
- data/docs/components/layout.rb +0 -91
- data/docs/components/markdown.rb +0 -25
- data/docs/components/nav/item.rb +0 -33
- data/docs/components/nav.rb +0 -6
- data/docs/components/tabs/tab.rb +0 -28
- data/docs/components/tabs.rb +0 -30
- data/docs/components/title.rb +0 -9
- data/docs/page_builder.rb +0 -39
- data/docs/pages/application_page.rb +0 -7
- data/docs/pages/helpers.rb +0 -97
- data/docs/pages/index.rb +0 -27
- data/docs/pages/library/collections.rb +0 -83
- data/docs/pages/rails/getting_started.rb +0 -57
- data/docs/pages/rails/helpers.rb +0 -55
- data/docs/pages/rails/layouts.rb +0 -61
- data/docs/pages/rails/migrating.rb +0 -37
- data/docs/pages/rails/rendering_views.rb +0 -35
- data/docs/pages/rails_integration.rb +0 -58
- data/docs/pages/templates.rb +0 -144
- data/docs/pages/testing/capybara.rb +0 -48
- data/docs/pages/testing/getting_started.rb +0 -44
- data/docs/pages/testing/nokogiri.rb +0 -83
- data/docs/pages/testing/rails.rb +0 -17
- data/docs/pages/translations.rb +0 -81
- data/docs/pages/views.rb +0 -184
- data/fixtures/compiler_test_helpers.rb +0 -19
- data/fixtures/content.rb +0 -60
- 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 -8
- 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/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 -11
- data/fixtures/standard_element.rb +0 -87
- data/fixtures/void_element.rb +0 -31
- 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/controller/USAGE +0 -10
- data/lib/generators/phlex/controller/controller_generator.rb +0 -54
- data/lib/generators/phlex/controller/templates/controller.rb.erb +0 -10
- data/lib/generators/phlex/controller/templates/view.rb.erb +0 -14
- data/lib/generators/phlex/layout/USAGE +0 -8
- data/lib/generators/phlex/layout/layout_generator.rb +0 -13
- data/lib/generators/phlex/layout/templates/layout.rb.erb +0 -31
- data/lib/generators/phlex/page/USAGE +0 -8
- data/lib/generators/phlex/page/page_generator.rb +0 -13
- data/lib/generators/phlex/page/templates/page.rb.erb +0 -13
- 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
- data/lib/generators/phlex/view/USAGE +0 -8
- data/lib/generators/phlex/view/templates/view.rb.erb +0 -14
- data/lib/generators/phlex/view/view_generator.rb +0 -21
- data/lib/install/phlex.rb +0 -39
- data/lib/phlex/block.rb +0 -16
- data/lib/phlex/compiler/elements.rb +0 -49
- data/lib/phlex/compiler/formatter.rb +0 -91
- data/lib/phlex/compiler/generators/content.rb +0 -103
- data/lib/phlex/compiler/generators/element.rb +0 -61
- data/lib/phlex/compiler/nodes/base.rb +0 -19
- data/lib/phlex/compiler/nodes/call.rb +0 -9
- data/lib/phlex/compiler/nodes/command.rb +0 -13
- data/lib/phlex/compiler/nodes/fcall.rb +0 -18
- data/lib/phlex/compiler/nodes/method_add_block.rb +0 -33
- data/lib/phlex/compiler/nodes/vcall.rb +0 -9
- data/lib/phlex/compiler/optimizer.rb +0 -66
- data/lib/phlex/compiler/visitors/base.rb +0 -15
- data/lib/phlex/compiler/visitors/file.rb +0 -29
- data/lib/phlex/compiler/visitors/stable_scope.rb +0 -28
- data/lib/phlex/compiler/visitors/statements.rb +0 -36
- data/lib/phlex/compiler/visitors/view.rb +0 -19
- data/lib/phlex/compiler/visitors/view_method.rb +0 -59
- data/lib/phlex/compiler.rb +0 -70
- data/lib/phlex/html/callbacks.rb +0 -11
- data/lib/phlex/markdown.rb +0 -76
- data/lib/phlex/rails/engine.rb +0 -10
- data/lib/phlex/rails/form.rb +0 -67
- data/lib/phlex/rails/helpers.rb +0 -118
- data/lib/phlex/rails/layout.rb +0 -15
- data/lib/phlex/rails.rb +0 -11
- data/lib/phlex/renderable.rb +0 -47
- data/lib/phlex/testing/capybara.rb +0 -25
- data/lib/phlex/testing/nokogiri.rb +0 -24
- data/lib/phlex/testing/rails.rb +0 -19
- data/lib/phlex/translation.rb +0 -23
- data/lib/tasks/phlex_tasks.rake +0 -11
- data/package-lock.json +0 -1195
- data/package.json +0 -5
- data/tailwind.config.js +0 -7
data/lib/phlex/rails/helpers.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
module Rails
|
5
|
-
module Helpers
|
6
|
-
module CSPMetaTag
|
7
|
-
def csp_meta_tag(**options)
|
8
|
-
if (output = @_view_context.csp_meta_tag(**options))
|
9
|
-
@_target << output
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module CSRFMetaTags
|
15
|
-
def csrf_meta_tags
|
16
|
-
if (output = @_view_context.csrf_meta_tags)
|
17
|
-
@_target << output
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module ActionCableMetaTag
|
23
|
-
def action_cable_meta_tag
|
24
|
-
if (output = @_view_context.action_cable_meta_tag)
|
25
|
-
@_target << output
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module FormWith
|
31
|
-
class BufferedFormWith < Phlex::Buffered
|
32
|
-
alias_method :check_box, :__output_method__
|
33
|
-
alias_method :collection_check_boxes, :__output_method__
|
34
|
-
alias_method :collection_radio_buttons, :__output_method__
|
35
|
-
alias_method :collection_select, :__output_method__
|
36
|
-
alias_method :color_field, :__output_method__
|
37
|
-
alias_method :date_field, :__output_method__
|
38
|
-
alias_method :date_select, :__output_method__
|
39
|
-
alias_method :datetime_field, :__output_method__
|
40
|
-
alias_method :datetime_local_field, :__output_method__
|
41
|
-
alias_method :datetime_select, :__output_method__
|
42
|
-
alias_method :email_field, :__output_method__
|
43
|
-
alias_method :file_field, :__output_method__
|
44
|
-
alias_method :grouped_collection_select, :__output_method__
|
45
|
-
alias_method :hidden_field, :__output_method__
|
46
|
-
alias_method :label, :__output_method__
|
47
|
-
alias_method :month_field, :__output_method__
|
48
|
-
alias_method :number_field, :__output_method__
|
49
|
-
alias_method :password_field, :__output_method__
|
50
|
-
alias_method :phone_field, :__output_method__
|
51
|
-
alias_method :radio_button, :__output_method__
|
52
|
-
alias_method :range_field, :__output_method__
|
53
|
-
alias_method :search_field, :__output_method__
|
54
|
-
alias_method :select, :__output_method__
|
55
|
-
alias_method :submit, :__output_method__
|
56
|
-
alias_method :telephone_field, :__output_method__
|
57
|
-
alias_method :text_area, :__output_method__
|
58
|
-
alias_method :text_field, :__output_method__
|
59
|
-
alias_method :time_field, :__output_method__
|
60
|
-
alias_method :time_select, :__output_method__
|
61
|
-
alias_method :time_zone_select, :__output_method__
|
62
|
-
alias_method :url_field, :__output_method__
|
63
|
-
alias_method :week_field, :__output_method__
|
64
|
-
alias_method :weekday_select, :__output_method__
|
65
|
-
alias_method :button, :__output_method__
|
66
|
-
end
|
67
|
-
|
68
|
-
def form_with(*args, **kwargs, &block)
|
69
|
-
@_target << @_view_context.form_with(*args, **kwargs) { |form|
|
70
|
-
capture do
|
71
|
-
yield(
|
72
|
-
BufferedFormWith.new(form, buffer: @_target)
|
73
|
-
)
|
74
|
-
end
|
75
|
-
}
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
module StylesheetLinkTag
|
80
|
-
def stylesheet_link_tag(*sources)
|
81
|
-
if (output = @_view_context.stylesheet_link_tag(*sources))
|
82
|
-
@_target << output
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
module FaviconLinkTag
|
88
|
-
def favicon_link_tag(*args)
|
89
|
-
if (output = @_view_context.favicon_link_tag(*args))
|
90
|
-
@_target << output
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
module PreloadLinkTag
|
96
|
-
def preload_link_tag(*args)
|
97
|
-
if (output = @_view_context.preload_link_tag(*args))
|
98
|
-
@_target << output
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
module JavaScriptIncludeTag
|
104
|
-
def javascript_include_tag(*sources)
|
105
|
-
if (output = @_view_context.javascript_include_tag(*sources))
|
106
|
-
@_target << output
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
module ContentFor
|
112
|
-
def content_for(slot, &block)
|
113
|
-
@_view_context.content_for(slot, capture(&block))
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
data/lib/phlex/rails/layout.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
module Rails
|
5
|
-
module Layout
|
6
|
-
include Helpers::CSPMetaTag
|
7
|
-
include Helpers::CSRFMetaTags
|
8
|
-
include Helpers::FaviconLinkTag
|
9
|
-
include Helpers::PreloadLinkTag
|
10
|
-
include Helpers::StylesheetLinkTag
|
11
|
-
include Helpers::ActionCableMetaTag
|
12
|
-
include Helpers::JavaScriptIncludeTag
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/phlex/rails.rb
DELETED
data/lib/phlex/renderable.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
module Renderable
|
5
|
-
def render(renderable, *args, **kwargs, &block)
|
6
|
-
if renderable.is_a?(HTML)
|
7
|
-
if block_given? && !block.binding.receiver.is_a?(Phlex::Block)
|
8
|
-
block = Phlex::Block.new(self, &block)
|
9
|
-
end
|
10
|
-
|
11
|
-
renderable.call(@_target, view_context: @_view_context, parent: self, &block)
|
12
|
-
elsif renderable.is_a?(Class) && renderable < Phlex::HTML
|
13
|
-
raise ArgumentError, "You tried to render the Phlex view class: #{renderable.name} but you probably meant to render an instance of that class instead."
|
14
|
-
else
|
15
|
-
@_target << @_view_context.render(renderable, *args, **kwargs, &block)
|
16
|
-
end
|
17
|
-
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def render_in(view_context, &block)
|
22
|
-
if block_given?
|
23
|
-
call(view_context: view_context) do |*args, **kwargs|
|
24
|
-
view_context.with_output_buffer(self) do
|
25
|
-
original_length = @_target.length
|
26
|
-
output = yield(*args, **kwargs)
|
27
|
-
unchanged = (original_length == @_target.length)
|
28
|
-
|
29
|
-
if unchanged
|
30
|
-
if defined?(ActiveSupport::SafeBuffer) && output.is_a?(ActiveSupport::SafeBuffer)
|
31
|
-
unsafe_raw(output)
|
32
|
-
else
|
33
|
-
text(output)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end.html_safe
|
38
|
-
else
|
39
|
-
call(view_context: view_context).html_safe
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def format
|
44
|
-
:html
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "capybara"
|
4
|
-
require_relative "view_helper"
|
5
|
-
|
6
|
-
module Phlex::Testing
|
7
|
-
module Capybara
|
8
|
-
module ViewHelper
|
9
|
-
include Phlex::Testing::ViewHelper
|
10
|
-
|
11
|
-
def self.included(klass)
|
12
|
-
if defined?(Minitest::Test) && klass < Minitest::Test
|
13
|
-
require "capybara/minitest"
|
14
|
-
include ::Capybara::Minitest::Assertions
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_accessor :page
|
19
|
-
|
20
|
-
def render(view, &block)
|
21
|
-
@page = ::Capybara::Node::Simple.new(super)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "nokogiri"
|
4
|
-
require_relative "view_helper"
|
5
|
-
|
6
|
-
module Phlex::Testing
|
7
|
-
module Nokogiri
|
8
|
-
module DocumentHelper
|
9
|
-
include Phlex::Testing::ViewHelper
|
10
|
-
|
11
|
-
def render(view, &block)
|
12
|
-
::Nokogiri::HTML5(super)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module FragmentHelper
|
17
|
-
include Phlex::Testing::ViewHelper
|
18
|
-
|
19
|
-
def render(view, &block)
|
20
|
-
::Nokogiri::HTML5.fragment(super)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/phlex/testing/rails.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "view_helper"
|
4
|
-
|
5
|
-
module Phlex::Testing
|
6
|
-
module Rails
|
7
|
-
module ViewHelper
|
8
|
-
include Phlex::Testing::ViewHelper
|
9
|
-
|
10
|
-
def view_context
|
11
|
-
controller.view_context
|
12
|
-
end
|
13
|
-
|
14
|
-
def controller
|
15
|
-
@controller ||= ActionView::TestCase::TestController.new
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/phlex/translation.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
module Translation
|
5
|
-
def self.included(view)
|
6
|
-
view.extend(ClassMethods)
|
7
|
-
end
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
attr_writer :translation_path
|
11
|
-
|
12
|
-
def translation_path
|
13
|
-
@translation_path ||= name&.split("::")&.join(".")&.downcase.to_s
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def translate(key, **options)
|
18
|
-
key = "#{self.class.translation_path}#{key}" if key.start_with?(".")
|
19
|
-
|
20
|
-
::I18n.translate(key, **options)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/tasks/phlex_tasks.rake
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :phlex do
|
4
|
-
desc "Install Phlex in the Rails application"
|
5
|
-
|
6
|
-
task :install do
|
7
|
-
install_file_path = File.expand_path("../install/phlex.rb", __dir__)
|
8
|
-
|
9
|
-
system "#{RbConfig.ruby} bin/rails app:template LOCATION=#{install_file_path}"
|
10
|
-
end
|
11
|
-
end
|