Phlex::HTML comes with methods that correspond to the most common HTML tags. You’ve seen the
h1 tag in the previous section.
You pass content as a block to a tag method. If the return value of the block is a
Float and no output methods were used, the return value will be output as text.
You can add attributes to HTML elements by passing keyword arguments to the methods.
_ are automatically converted to dashes
Symbol keys. If you need to use an underscore in an attribute name, you can pass it as a
You can pass a
Hash as an attribute value and the Hash will be flattened with a dash between each level.
When an attribute value is
true, the attribute name will be output without a value; when falsy, the attribute isn’t output at all. You can use the strings
"false" as values for non-boolean attributes.
The template tag
template method is used to define the view template itself, you'll need to use the method
template_tag if you want to to render an HTML
Registering custom tags
You can register custom elements with the
register_element macro. The custom element will only be available in the view where it is registered and subclasses of that view.