Class: Rhtml::Html
- Inherits:
-
Object
- Object
- Rhtml::Html
- Defined in:
- lib/rhtml/html.rb
Instance Method Summary collapse
-
#initialize(content = '', indent = 0, &b) ⇒ Html
constructor
A new instance of Html.
- #raw!(string = '') ⇒ Object (also: #==)
- #tag!(tag_name, ps = {}, str = nil, &b) ⇒ Object
- #to_s ⇒ Object
- #void_tag!(tag_name, ps = {}) ⇒ Object
Constructor Details
#initialize(content = '', indent = 0, &b) ⇒ Html
Returns a new instance of Html.
3 4 5 6 7 8 9 |
# File 'lib/rhtml/html.rb', line 3 def initialize(content='', indent=0, &b) @__indent = 0 @__content = content @__cls = nil @__id = nil instance_eval(&b) if block_given? end |
Instance Method Details
#raw!(string = '') ⇒ Object Also known as: ==
49 50 51 |
# File 'lib/rhtml/html.rb', line 49 def raw! string='' @__content << string.to_s << "\n" end |
#tag!(tag_name, ps = {}, str = nil, &b) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rhtml/html.rb', line 11 def tag!(tag_name, ps={}, str=nil, &b) str, ps = ps, {} if ps.is_a? String ps[:class] = @__cls if @__cls ps[:id] = @__id if @__id @__content << Rhtml.tag_open(tag_name, ps, @__indent) @__cls = @__id = nil @__indent += 1 if str @__content << INDENT * @__indent << str << "\n" elsif block_given? ret = instance_eval &b @__content << INDENT * @__indent << ret.to_s << "\n" if ret.is_a?(String) end @__indent -= 1 @__content << Rhtml.tag_close(tag_name, @__indent) self end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/rhtml/html.rb', line 54 def to_s @__content end |