hrb/test/fixtures/complex.html.rb

46 lines
1.2 KiB
Ruby

# 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