abstract class
Components::Elements::HTMLElement
- Components::Elements::HTMLElement
- Reference
- Object
Overview
Abstract base class for all HTML elements
Direct Known Subclasses
Defined in:
components/elements/base/html_element.crConstructors
Instance Method Summary
-
#[](name : String) : String | Nil
Get an attribute value
-
#add_class(class_names : String) : self
Add CSS classes
-
#add_style(styles : String) : self
Add inline styles
- #attributes : Hash(String, String)
-
#can_have_children? : Bool
Check if this element can contain children
- #children : Array(HTMLElement | String | RawHTML)
-
#has_class?(class_name : String) : Bool
Check if element has a specific class
-
#remove_attribute(name : String) : self
Remove an attribute
-
#remove_class(class_names : String) : self
Remove CSS classes
-
#render : String
Abstract render method to be implemented by subclasses
-
#set_attribute(name : String, value : String | Nil) : self
Set an attribute with validation
-
#set_safe_style(style : SafeStyleValue) : self
Sets the
styleattribute from a validatedSafeStyleValue(the output ofSafeStyle#build). -
#set_safe_url_attribute(name : String, url : SafeURL) : self
Sets a URL-bearing attribute (
href,src,action,formaction,poster,cite,ping,xlink:href, meta-refreshcontent, ...) from a validatedSafeURL. - #tag_name : String
-
#to_s(io : IO) : Nil
Convert to string (alias for render)
-
#void_element? : Bool
Check if this is a void element
Constructor Detail
Instance Method Detail
Sets the style attribute from a validated SafeStyleValue (the
output of SafeStyle#build). There is no overload that accepts a
bare String for this — that is the "raw style attribute" ban from
docs/SAFE_HTML_V1.md.
Sets a URL-bearing attribute (href, src, action, formaction,
poster, cite, ping, xlink:href, meta-refresh content, ...)
from a validated SafeURL. Scheme validation happened when the
SafeURL was constructed (SafeURL.parse!); the value still passes
through the normal attribute-escaping path when rendered.