|
|
|
@ -5,12 +5,12 @@ class App < Roda
|
|
|
|
|
|
|
|
|
|
route do |r|
|
|
|
|
|
r.root do
|
|
|
|
|
render "hello"
|
|
|
|
|
# render("hello", locals: {name: "Alice"})
|
|
|
|
|
view("hello", locals: {name: "Alice"})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
require "tilt/template"
|
|
|
|
|
require "phlex"
|
|
|
|
|
|
|
|
|
@ -19,28 +19,30 @@ module Tilt
|
|
|
|
|
def prepare
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# def evaluate(scope, locals)
|
|
|
|
|
# klass = Class.new(Phlex::HTML)
|
|
|
|
|
# klass.class_eval(data, __FILE__, __LINE__)
|
|
|
|
|
# klass.new.()
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
def precompiled_template(*)
|
|
|
|
|
data
|
|
|
|
|
# I have no idea how this works - it's just copied pretty much blindly from here:
|
|
|
|
|
#
|
|
|
|
|
# https://github.com/phlex-ruby/phlex-rails/blob/main/lib/phlex/rails/layout.rb#L18
|
|
|
|
|
def evaluate(scope, locals, &block)
|
|
|
|
|
klass = Class.new(Phlex::HTML)
|
|
|
|
|
klass.class_eval(data, __FILE__, __LINE__)
|
|
|
|
|
component = klass.new(**locals)
|
|
|
|
|
component.call do |yielded|
|
|
|
|
|
output = yield
|
|
|
|
|
component.unsafe_raw(output)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def precompiled_preamble(*)
|
|
|
|
|
<<~RUBY
|
|
|
|
|
klass = Class.new(Phlex::HTML) do
|
|
|
|
|
RUBY
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def precompiled_postamble(*)
|
|
|
|
|
<<~RUBY
|
|
|
|
|
end
|
|
|
|
|
klass.new.call
|
|
|
|
|
RUBY
|
|
|
|
|
end
|
|
|
|
|
# Not sure if this is better...?
|
|
|
|
|
# def precompiled_preamble(*) = "klass = Class.new(Phlex::HTML) do"
|
|
|
|
|
# def precompiled_template(*) = data
|
|
|
|
|
# def precompiled_postamble(locals) = <<~RUBY
|
|
|
|
|
# end
|
|
|
|
|
# component = klass.new(**locals)
|
|
|
|
|
# component.call do |yielded|
|
|
|
|
|
# output = yield
|
|
|
|
|
# component.unsafe_raw(output)
|
|
|
|
|
# end
|
|
|
|
|
# RUBY
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|