Class: InlineTag
- Inherits:
-
ActiveComponent::Base
- Object
- ActiveComponent::Base
- InlineTag
- Defined in:
- lib/active_component/components/inline_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, &content_block) ⇒ InlineTag
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, &content_block) ⇒ InlineTag
Content can be passed as a block
8 9 10 11 12 13 |
# File 'lib/active_component/components/inline_tag.rb', line 8 def initialize(*args, &content_block) init_component(args, [:content, :title, :tag_type, :attributes], &content_block) # Defaults @tag_type ||= :span end |
Instance Attribute Details
#tag_type ⇒ Object
Returns the value of attribute tag_type.
5 6 7 |
# File 'lib/active_component/components/inline_tag.rb', line 5 def tag_type @tag_type end |
Instance Method Details
#to_html ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/active_component/components/inline_tag.rb', line 15 def to_html if ActiveComponent::Config.[:validate_html] raise InvalidHtmlError, "Inline tags must not have blocks as inner content." if content.includes_a? Block end wrap_contents(@tag_type, content, nil, @attributes) end |