HTML+ERB
Opening Tags
Script Tag (<%
)
html
<% "String" %>
json
{
type: "erb-loud",
language: "ruby",
value: {
// Prism return value
}
}
Expression Tag (<%=
)
html
<%= "String" %>
json
{
type: "erb-loud",
language: "ruby",
value: {
// Prism return value
}
}
Raw text output Tag (<%==
)
html
<%== "String" %>
json
{
type: "erb-loud",
language: "ruby",
value: {
// Prism return value
}
}
Comment Tag (<%#
)
Can also be seen as <% #
.
html
<%# Comment %>
json
{
type: "erb-comment",
language: "ruby",
value: {
// Prism return value
}
}
??? Tag (<%-
)
html
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
??? Tag (<%%
)
html
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Closing tags
??? Tag (%>
)
html
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
??? Tag (%%>
)
html
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
??? Tag (-%>
)
html
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Attribute Value interpolation
Interpolate attribute value
html
<article id="<%= dom_id(article) %>"></article>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Interpolate attribute value with static value
html
<article class="article <%= classes_for(article) %>"></article>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Attributes Interpolation
Output
html
<input <%= "type='text' %> />
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Conditional
html
<input <% if true %> type="text" <% end %> />
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Conditionals
Tag Children
html
<% if true %>
<h1><%= "Hello World" %></h1>
<% end %>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Loops
Tag Children
html
<% @posts.each do |post| %>
<h1><%= post.title %></h1>
<% end %>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Blocks
TODO
Rails Tag Helpers
content_tag
html
<%= content_tag(:p, "Hello world!") %>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
tag.<tag name>
html
<%= tag.div tag.p("Hello world!") %>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
tag.<tag name>
with block
html
<%= tag.p do %>
Hello world!
<% end %>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
tag.<tag name>
with attributes
html
<%= tag.section class: ["bg-black text-white"] %>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
tag.attributes
html
<input <%= tag.attributes(type: :text, aria: { label: "Search" }) %>>
json
{
type: "erb-???",
language: "ruby",
value: {
// Prism return value
}
}
Disallowed
We should disallow/discourage the following patterns
Dynamic tag names
html
<<%= "input" %> required />
Dynamic Attribute names
html
<input <%= "type" %>="text" />