-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimenting with a `to_proc` interface on SGML components.
- Loading branch information
1 parent
cd11602
commit cd1234b
Showing
2 changed files
with
38 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
class App < Phlex::HTML | ||
def view_template | ||
render Example do |e| | ||
e.slot(&Sub.new) | ||
end | ||
end | ||
end | ||
|
||
class Example < Phlex::HTML | ||
def view_template(&) | ||
article(&) | ||
end | ||
|
||
def slot(&) | ||
render(&) | ||
end | ||
end | ||
|
||
class Sub < Phlex::HTML | ||
def view_template | ||
h1 { "Sub" } | ||
end | ||
end | ||
|
||
test do | ||
expect(App.new.call) == "<article><h1>Sub</h1></article>" | ||
end |