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
- #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 |
# File 'lib/rhtml/html.rb', line 3 def initialize(content='', indent=0, &b) @indent = 0 @content = content @content << instance_eval(&b) if block_given? end |
Instance Method Details
#raw!(string = '') ⇒ Object
41 42 43 |
# File 'lib/rhtml/html.rb', line 41 def raw! string='' @content << string.to_s << "\n" end |
#tag!(tag_name, ps = {}, str = nil, &b) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rhtml/html.rb', line 9 def tag!(tag_name, ps={}, str=nil, &b) str, ps = ps, {} if ps.is_a? String @content << Rhtml.tag_open(tag_name, ps, @indent) @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
45 46 47 |
# File 'lib/rhtml/html.rb', line 45 def to_s @content end |