Class: HtmlRB::Tag
- Inherits:
-
Object
- Object
- HtmlRB::Tag
- Defined in:
- lib/html_rb/tag.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, content = nil, **attrs, &block) ⇒ Tag
constructor
A new instance of Tag.
- #to_s ⇒ Object
Constructor Details
#initialize(name = nil, content = nil, **attrs, &block) ⇒ Tag
Returns a new instance of Tag.
3 4 5 6 |
# File 'lib/html_rb/tag.rb', line 3 def initialize(name=nil,content=nil,**attrs,&block) @strings = [] tag name, content, **attrs, &block end |
Class Method Details
.register(tag_name, void: false) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/html_rb/tag.rb', line 12 def self.register(tag_name, void: false) method_name = tag_name.to_s.downcase.gsub('-','_') # Rubify the tag name. define_method(method_name) do |content=nil,**attrs,&block| tag tag_name, content, _void: void, **attrs, &block end end |
.unregister(tag_name) ⇒ Object
19 20 21 22 |
# File 'lib/html_rb/tag.rb', line 19 def self.unregister(tag_name) method_name = tag_name.to_s.downcase.gsub('-','_') # Rubify the tag name. remove_method method_name end |
Instance Method Details
#to_s ⇒ Object
8 9 10 |
# File 'lib/html_rb/tag.rb', line 8 def to_s @strings.join end |