Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions browser_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 0 additions & 45 deletions lib/phlex/sgml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
48 changes: 0 additions & 48 deletions quickdraw/erb.test.rb

This file was deleted.

Loading