From c3d90351044c3f6b3406e678753852d7e29906b4 Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Sat, 17 Jan 2026 17:12:44 +0000 Subject: [PATCH] Remove experimental ERB support --- browser_tests.rb | 5 ----- lib/phlex/sgml.rb | 45 ---------------------------------------- quickdraw/erb.test.rb | 48 ------------------------------------------- 3 files changed, 98 deletions(-) delete mode 100644 quickdraw/erb.test.rb diff --git a/browser_tests.rb b/browser_tests.rb index 84eac57b..27bbe615 100755 --- a/browser_tests.rb +++ b/browser_tests.rb @@ -109,15 +109,10 @@ def view_template s.cdata(line) s.cdata { line } end - erb_snippet(line:) end end end end - - erb :erb_snippet, <<~HTML, locals: %(line:) - <%= @line %> - HTML end class XSSWithSymbols < Phlex::HTML diff --git a/lib/phlex/sgml.rb b/lib/phlex/sgml.rb index cd54dbef..0eae06da 100644 --- a/lib/phlex/sgml.rb +++ b/lib/phlex/sgml.rb @@ -2,17 +2,6 @@ # **Standard Generalized Markup Language** for behaviour common to {HTML} and {SVG}. class Phlex::SGML - ERBCompiler = ERB::Compiler.new("<>").tap do |compiler| - compiler.pre_cmd = [""] - compiler.put_cmd = "@_state.buffer.<<" - compiler.insert_cmd = "__implicit_output__" - compiler.post_cmd = ["nil"] - - def compiler.add_insert_cmd(out, content) - out.push("#{@insert_cmd}((#{content}))") - end - end - include Phlex::Helpers class << self @@ -32,40 +21,6 @@ def new(*a, **k, &block) super end end - - def erb(method_name, erb = nil, locals: nil, &block) - loc = caller_locations(1, 1)[0] - path = loc.path.delete_suffix(".rb") - file = loc.path - line = loc.lineno - 1 - - unless erb - method_path = "#{path}/#{method_name}.html.erb" - sidecar_path = "#{path}.html.erb" - - if File.exist?(method_path) - erb = File.read(method_path) - file = method_path - line = 1 - elsif method_name == :view_template && File.exist?(sidecar_path) - erb = File.read(sidecar_path) - file = sidecar_path - line = 1 - else - raise Phlex::RuntimeError.new(<<~MESSAGE) - No ERB template found for #{method_name} - MESSAGE - end - end - - code, _enc = ERBCompiler.compile(erb) - - class_eval(<<~RUBY, file, line) - def #{method_name} #{locals} - #{code} - end - RUBY - end end def view_template diff --git a/quickdraw/erb.test.rb b/quickdraw/erb.test.rb deleted file mode 100644 index 838074a0..00000000 --- a/quickdraw/erb.test.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -class Example < Phlex::HTML - def initialize - @text = "text" - @html = safe "
html
" - end - - erb :view_template, <<~ERB - <% card do %> -

<%= @text %>

- <%= @html %> - <%= phlex_snippet %> - <% end %> - ERB - - erb :erb_snippet, <<~ERB, locals: %(text:) -

Goodbye <%= text %>

- ERB - - def phlex_snippet - p { "How do you do?" } - end - - def card - section do - article do - yield - end - erb_snippet(text: "Joel") - end - end -end - -test do - output = Example.call - - assert_equivalent_html output, <<~HTML -
-
-

text

-
html
-

How do you do?

-
-

Goodbye Joel

-
- HTML -end