Class: Rxhp::HtmlSingletonElement
- Inherits:
-
HtmlElement
- Object
- Element
- HtmlElement
- Rxhp::HtmlSingletonElement
- Defined in:
- lib/rxhp/html_singleton_element.rb
Overview
Superclass for all HTML elements that should never have children.
This is enforced. Examples include
, <img> etc
There is never a close tag:
-
in HTML it would be optional (and meaningless) anyway
-
people don’t expect to see them
-
in XHTML, the opening tag will have been self closing.
Defined Under Namespace
Classes: HasChildrenError
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
-
#validate! ⇒ Object
Check that there are no child elements.
Methods inherited from HtmlElement
#render, #render_children, #tag_name
Methods included from AttributeValidator
match?, #valid_attributes?, #validate_attributes!
Methods inherited from Element
#children?, #fill_options, #initialize, #render, #render_children, #render_string, #valid?
Methods included from Scope
current, define_element, #fragment, with_parent
Constructor Details
This class inherits a constructor from Rxhp::Element
Instance Method Details
#validate! ⇒ Object
Check that there are no child elements.
23 24 25 26 |
# File 'lib/rxhp/html_singleton_element.rb', line 23 def validate! super raise HasChildrenError.new unless children.empty? end |