Hrb: not as good as I thought
This commit is contained in:
23
test/fixtures/basic.html.rb
vendored
Normal file
23
test/fixtures/basic.html.rb
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
doctype
|
||||
html do
|
||||
head do
|
||||
title "Hello!"
|
||||
meta charset: "utf-8"
|
||||
meta name: "viewport", content: "width=device-width, initial-scale=1"
|
||||
link rel: "stylesheet", href: "/test.css"
|
||||
meta name: "created", content: created
|
||||
end
|
||||
|
||||
body do
|
||||
div(id: "content") do
|
||||
div(class: "container") do
|
||||
h1("Hello!")
|
||||
numbers.each do |i|
|
||||
div("This is div ##{i}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
45
test/fixtures/complex.html.rb
vendored
Normal file
45
test/fixtures/complex.html.rb
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
def pet(name:, kind:, favorite_food:)
|
||||
div(class: "pet") do
|
||||
strong(name)
|
||||
text(" the ")
|
||||
em(kind)
|
||||
text(" likes ")
|
||||
em(favorite_food)
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/BlockLength
|
||||
doctype
|
||||
html(lang: "en-us") do
|
||||
head do
|
||||
title "My pets"
|
||||
meta "http-equiv" => "Content-Type", content: "text/html; charset=utf-8"
|
||||
end
|
||||
|
||||
body do
|
||||
header(class: "top") do
|
||||
h1("My pets")
|
||||
end
|
||||
|
||||
main(class: "content") do
|
||||
subjects = [
|
||||
{name: "Orion", kind: "dog", favorite_food: "icing"},
|
||||
{name: "Finn", kind: "dog", favorite_food: "beef"},
|
||||
{name: "Mao", kind: "cat", favorite_food: "canned cat food"},
|
||||
{name: "Stella", kind: "cat", favorite_food: "hate"},
|
||||
{name: "Teemo", kind: "cat", favorite_food: "tuna"},
|
||||
{name: "Merlin", kind: "cat", favorite_food: "tuna"},
|
||||
{name: "Taakoyaki", kind: "axolotl", favorite_food: "earthworms"},
|
||||
]
|
||||
|
||||
subjects.each do |subject|
|
||||
pet(name: subject[:name], kind: subject[:kind], favorite_food: subject[:favorite_food])
|
||||
end
|
||||
|
||||
text("<script>console.log('This is escape')</script>")
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/BlockLength
|
Reference in New Issue
Block a user