You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
720 B
48 lines
720 B
1 year ago
|
require "roda"
|
||
|
|
||
|
class App < Roda
|
||
|
plugin :render, engine: :phlex
|
||
|
|
||
|
route do |r|
|
||
|
r.root do
|
||
|
render "hello"
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
require "tilt/template"
|
||
|
require "phlex"
|
||
|
|
||
|
module Tilt
|
||
|
class PhlexTemplate < Template
|
||
|
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
|
||
|
end
|
||
|
|
||
|
def precompiled_preamble(*)
|
||
|
<<~RUBY
|
||
|
klass = Class.new(Phlex::HTML) do
|
||
|
RUBY
|
||
|
end
|
||
|
|
||
|
def precompiled_postamble(*)
|
||
|
<<~RUBY
|
||
|
end
|
||
|
klass.new.call
|
||
|
RUBY
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
Tilt.register(Tilt::PhlexTemplate, "phlex")
|