HTML::Builder
HTML::Builder is a library for representing HTML in Crystal.
Usage:
html = HTML::Builder.new.a({href: "google.com"}) do
text "crystal is awesome"
end
puts html # => "<a href="google.com">crystal is awesome</a>
Or also you can use #build method:
HTML::Builder.new.build do
a({href: "google.com"}) do
text "crystal is awesome"
end
end # => "<a href="google.com">crystal is awesome</a>
Renders A html tag with any options.
Renders B html tag with any options.
Renders BODY html tag with any options.
Renders BR html tag.
Renders BUTTON html tag with any options.
Renders DIV html tag with any options.
Renders HTML doctype tag.
Renders EM html tag with any options.
Renders FORM html tag with any options.
Renders H1 html tag with any options.
Renders H2 html tag with any options.
Renders H3 html tag with any options.
Renders HEAD html tag with any options.
Renders HR html tag.
Renders HTML html tag with any options.
Renders I html tag with any options.
Renders IMG html tag with any options.
Renders INPUT html tag with any options.
Renders LI html tag with any options.
Renders LINK html tag with any options.
Renders OL html tag with any options.
Renders P html tag with any options.
Renders S html tag with any options.
Renders SCRIPT html tag with any options.
Renders SPAN html tag with any options.
Renders STRONG html tag with any options.
Renders TABLE html tag with any options.
Renders TBODY html tag with any options.
Renders TD html tag with any options.
Renders escaped text in html tag.
Renders TEXTAREA html tag with any options.
Renders THEAD html tag with any options.
Renders TITLE html tag with any options.
Renders TR html tag with any options.
Renders U html tag with any options.
Renders UL html tag with any options.
Renders A html tag with any options.
HTML::Builder.new.build do
a({ class: "crystal" }) { text "crystal is awesome" }
end
# => <a class="crystal">crystal is awesome</a>Renders B html tag with any options.
HTML::Builder.new.build do
b({ class: "crystal" }) { text "crystal is awesome" }
end
# => <b class="crystal">crystal is awesome</b>Renders BODY html tag with any options.
HTML::Builder.new.build do
body({ class: "crystal" }) { text "crystal is awesome" }
end
# => <body class="crystal">crystal is awesome</body>Renders BR html tag.
HTML::Builder.new.build { br } # => <br/>Renders BUTTON html tag with any options.
HTML::Builder.new.build do
button({ class: "crystal" }) { text "crystal is awesome" }
end
# => <button class="crystal">crystal is awesome</button>Renders DIV html tag with any options.
HTML::Builder.new.build do
div({ class: "crystal" }) { text "crystal is awesome" }
end
# => <div class="crystal">crystal is awesome</div>Renders HTML doctype tag.
HTML::Builder.new.build { doctype } # => <doctype/>Renders EM html tag with any options.
HTML::Builder.new.build do
em({ class: "crystal" }) { text "crystal is awesome" }
end
# => <em class="crystal">crystal is awesome</em>Renders FORM html tag with any options.
HTML::Builder.new.build do
form({ class: "crystal" }) { text "crystal is awesome" }
end
# => <form class="crystal">crystal is awesome</form>Renders H1 html tag with any options.
HTML::Builder.new.build do
h1({ class: "crystal" }) { text "crystal is awesome" }
end
# => <h1 class="crystal">crystal is awesome</h1>Renders H2 html tag with any options.
HTML::Builder.new.build do
h2({ class: "crystal" }) { text "crystal is awesome" }
end
# => <h2 class="crystal">crystal is awesome</h2>Renders H3 html tag with any options.
HTML::Builder.new.build do
h3({ class: "crystal" }) { text "crystal is awesome" }
end
# => <h3 class="crystal">crystal is awesome</h3>Renders HEAD html tag with any options.
HTML::Builder.new.build do
head({ class: "crystal" }) { text "crystal is awesome" }
end
# => <head class="crystal">crystal is awesome</head>Renders HR html tag.
HTML::Builder.new.build { hr } # => <hr/>Renders HTML html tag with any options.
HTML::Builder.new.build do
html({ class: "crystal" }) { text "crystal is awesome" }
end
# => <html class="crystal">crystal is awesome</html>Renders I html tag with any options.
HTML::Builder.new.build do
i({ class: "crystal" }) { text "crystal is awesome" }
end
# => <i class="crystal">crystal is awesome</i>Renders IMG html tag with any options.
HTML::Builder.new.build do
img({ class: "crystal" })
end
# => <img class="crystal">Renders INPUT html tag with any options.
HTML::Builder.new.build do
input({ class: "crystal" })
end
# => <input class="crystal">Renders LI html tag with any options.
HTML::Builder.new.build do
li({ class: "crystal" }) { text "crystal is awesome" }
end
# => <li class="crystal">crystal is awesome</li>Renders LINK html tag with any options.
HTML::Builder.new.build do
link({ class: "crystal" })
end
# => <link class="crystal">Renders OL html tag with any options.
HTML::Builder.new.build do
ol({ class: "crystal" }) { text "crystal is awesome" }
end
# => <ol class="crystal">crystal is awesome</ol>Renders P html tag with any options.
HTML::Builder.new.build do
p({ class: "crystal" }) { text "crystal is awesome" }
end
# => <p class="crystal">crystal is awesome</p>Renders S html tag with any options.
HTML::Builder.new.build do
s({ class: "crystal" }) { text "crystal is awesome" }
end
# => <s class="crystal">crystal is awesome</s>Renders SCRIPT html tag with any options.
HTML::Builder.new.build do
script({ class: "crystal" }) { text "crystal is awesome" }
end
# => <script class="crystal">crystal is awesome</script>Renders SPAN html tag with any options.
HTML::Builder.new.build do
span({ class: "crystal" }) { text "crystal is awesome" }
end
# => <span class="crystal">crystal is awesome</span>Renders STRONG html tag with any options.
HTML::Builder.new.build do
strong({ class: "crystal" }) { text "crystal is awesome" }
end
# => <strong class="crystal">crystal is awesome</strong>Renders TABLE html tag with any options.
HTML::Builder.new.build do
table({ class: "crystal" }) { text "crystal is awesome" }
end
# => <table class="crystal">crystal is awesome</table>Renders TBODY html tag with any options.
HTML::Builder.new.build do
tbody({ class: "crystal" }) { text "crystal is awesome" }
end
# => <tbody class="crystal">crystal is awesome</tbody>Renders TD html tag with any options.
HTML::Builder.new.build do
td({ class: "crystal" }) { text "crystal is awesome" }
end
# => <td class="crystal">crystal is awesome</td>Renders escaped text in html tag.
HTML::Builder.new.build { text "crystal is awesome" }
# => crystal is awesomeRenders TEXTAREA html tag with any options.
HTML::Builder.new.build do
textarea({ class: "crystal" }) { text "crystal is awesome" }
end
# => <textarea class="crystal">crystal is awesome</textarea>Renders THEAD html tag with any options.
HTML::Builder.new.build do
thead({ class: "crystal" }) { text "crystal is awesome" }
end
# => <thead class="crystal">crystal is awesome</thead>Renders TITLE html tag with any options.
HTML::Builder.new.build do
title({ class: "crystal" }) { text "crystal is awesome" }
end
# => <title class="crystal">crystal is awesome</title>Renders TR html tag with any options.
HTML::Builder.new.build do
tr({ class: "crystal" }) { text "crystal is awesome" }
end
# => <tr class="crystal">crystal is awesome</tr>Renders U html tag with any options.
HTML::Builder.new.build do
u({ class: "crystal" }) { text "crystal is awesome" }
end
# => <u class="crystal">crystal is awesome</u>Renders UL html tag with any options.
HTML::Builder.new.build do
ul({ class: "crystal" }) { text "crystal is awesome" }
end
# => <ul class="crystal">crystal is awesome</ul>