-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build HTML and SVG with an inline DSL (#860)
Co-authored-by: Marco Roth <[email protected]> Co-authored-by: Will Cosgrove <[email protected]>
- Loading branch information
1 parent
41a58c8
commit 168ad4b
Showing
2 changed files
with
58 additions
and
0 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,28 @@ | ||
# frozen_string_literal: true | ||
|
||
test "inline html with no param" do | ||
output = Phlex.html do | ||
h1 { "Hi" } | ||
end | ||
|
||
assert_equal_html output, <<~HTML.strip | ||
<h1>Hi</h1> | ||
HTML | ||
end | ||
|
||
def title = "Hello" | ||
|
||
test "inline html with a yield param" do | ||
@ivar = "Hi" | ||
h1 = "foo" | ||
|
||
output = Phlex.html do |receiver| | ||
h1 { h1 } | ||
h1 { @ivar } | ||
title { receiver.title } | ||
end | ||
|
||
assert_equal_html output, <<~HTML.strip | ||
<h1>foo</h1><h1>Hi</h1><title>Hello</title> | ||
HTML | ||
end |