-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML-15 Properly implement HTML5 void-elements
- Loading branch information
1 parent
cb066f2
commit ef7e270
Showing
4 changed files
with
128 additions
and
22 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,66 @@ | ||
require "../spec_helper" | ||
|
||
module ToHtml::InstanceTemplate::VoidElementSpec | ||
class MyView | ||
ToHtml.class_template do | ||
div do | ||
span { "First line" } | ||
br | ||
span { "Second line" } | ||
hr | ||
embed MyVideo.new("/media/video.mp4") | ||
hr | ||
form action: "/inputs", method: "POST" do | ||
input MyInputField.new("foo"), placeholder: "bar" | ||
input type: "submit", name: "submit", value: "Submit" | ||
end | ||
end | ||
end | ||
end | ||
|
||
class MyVideo | ||
getter path : String | ||
|
||
def initialize(@path); end | ||
|
||
ToHtml.instance_tag_attrs do | ||
type = "video/webm" | ||
src = path | ||
width = "250" | ||
height = "200" | ||
end | ||
end | ||
|
||
class MyInputField | ||
getter field_value : String | ||
|
||
def initialize(@field_value); end | ||
|
||
ToHtml.instance_tag_attrs do | ||
type = "text" | ||
name = "name" | ||
value = field_value | ||
end | ||
end | ||
|
||
describe "MyView.to_html" do | ||
it "should render void elements correctly" do | ||
expected = <<-HTML.squish | ||
<div> | ||
<span>First line</span> | ||
<br> | ||
<span>Second line</span> | ||
<hr> | ||
<embed type="video/webm" src="/media/video.mp4" width="250" height="200"> | ||
<hr> | ||
<form action="/inputs" method="POST"> | ||
<input type="text" name="name" value="foo" placeholder="bar"> | ||
<input type="submit" name="submit" value="Submit"> | ||
</form> | ||
</div> | ||
HTML | ||
|
||
MyView.to_html.should eq(expected) | ||
end | ||
end | ||
end |
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