Alpha Chen 2 years ago
parent 5864e3f464
commit 019a31f483
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -122,11 +122,20 @@ module Tilt
#
# https://github.com/phlex-ruby/phlex-rails/blob/main/lib/phlex/rails/layout.rb#L18
def evaluate(scope, locals, &block)
p scope
p locals
klass = Class.new(Phlex::HTML)
klass.class_eval(data, __FILE__, __LINE__)
component = klass.new(**locals)
component = klass.new
scope.instance_variables
.reject { _2.start_with?("@_") }
.each do |k|
component.instance_variable_set(k, scope.instance_variable_get(k))
end
locals.each do |k,v|
component.instance_variable_set("@#{k}", v)
end
component.call do |yielded|
output = yield
component.unsafe_raw(output)

@ -1,7 +1,3 @@
def initialize(name:)
@name = name
end
def template
h1 { "👋 Hello #@name!" }
end

Loading…
Cancel
Save