Class: EmptyTag
- Inherits:
-
ActiveComponent::Base
- Object
- ActiveComponent::Base
- EmptyTag
- Defined in:
- lib/active_component/components/empty_tag.rb
Constant Summary
Constants included from ActiveComponent
ActiveComponent::BLOCK_ELEMENTS, ActiveComponent::EMPTY_ELEMENTS, ActiveComponent::HEADING_ELEMENTS, ActiveComponent::HTML5_ELEMENTS, ActiveComponent::PHRASING_ELEMENTS, ActiveComponent::SECTION_ELEMENTS
Instance Attribute Summary collapse
-
#tag_type ⇒ Object
Returns the value of attribute tag_type.
Attributes inherited from ActiveComponent::Base
#attributes, #childrenHash, #node_content, #node_name, #parent, #title
Instance Method Summary collapse
-
#initialize(*args) ⇒ EmptyTag
constructor
Content can be passed as a block.
- #to_html ⇒ Object
Methods inherited from ActiveComponent::Base
#<<, #<=>, #[], #add, #breadth, #breadth_each, #children, #class_name, #content, #content=, def_component_helper, def_html_sub_components, #depth, #detached_copy, #each, #each_leaf, #firstChild, #firstSibling, #freezeTree!, #hasChildren?, #hasnode_content?, #html_class, #in_degree, inherited, #init_component, #init_node, #isFirstSibling?, #isLastSibling?, #isLeaf?, #isOnlyChild?, #is_html_tag_wrapper?, #is_root?, json_create, #lastChild, #lastSibling, #length, #marshal_dump, #marshal_load, #nextSibling, #nodeDepth, #nodeHeight, #out_degree, #parentage, #preordered_each, #prepend, #previousSibling, #printTree, #remove!, #removeAll!, #removeFromParent!, #root, #siblings, #size, #to_json, #to_s
Methods included from Enumerable
#find_a, #includes_a?, #transmogrify
Methods included from ActiveComponent
#print_contents, #print_object, #print_tag, #wrap_contents
Constructor Details
#initialize(*args) ⇒ EmptyTag
Content can be passed as a block
8 9 10 11 12 13 |
# File 'lib/active_component/components/empty_tag.rb', line 8 def initialize(*args) init_component(args, [:title, :tag_type, :attributes]) # Defaults @tag_type ||= :br end |
Instance Attribute Details
#tag_type ⇒ Object
Returns the value of attribute tag_type.
5 6 7 |
# File 'lib/active_component/components/empty_tag.rb', line 5 def tag_type @tag_type end |
Instance Method Details
#to_html ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/active_component/components/empty_tag.rb', line 15 def to_html if ActiveComponent::Config.[:validate_html] raise InvalidHtmlError, "Empty HTML elements must not have content." if content.present? end name, attrs = merge_name_and_attributes(@tag_type.to_s, @attributes) attrs = Haml::Precompiler.build_attributes(@haml_buffer.html?, @haml_buffer.[:attr_wrapper], attrs) "<#{name}#{attrs} />" end |