Class: Rxhp::HtmlSingletonElement

Inherits:
HtmlElement show all
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

#attributes, #children

Instance Method Summary collapse

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, with_parent

Constructor Details

This class inherits a constructor from Rxhp::Element

Instance Method Details

#validate!Object

Check that there are no child elements.

Raises:


23
24
25
26
# File 'lib/rxhp/html_singleton_element.rb', line 23

def validate!
  super
  raise HasChildrenError.new unless children.empty?
end