Class: Rhtml::Html
- Inherits:
-
Object
- Object
- Rhtml::Html
- Defined in:
- lib/rhtml/html.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#indent ⇒ Object
Returns the value of attribute indent.
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.
5 6 7 8 9 |
# File 'lib/rhtml/html.rb', line 5 def initialize(content='', indent=0, &b) @indent = 0 @content = content @content << instance_eval(&b) if block_given? end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/rhtml/html.rb', line 3 def content @content end |
#indent ⇒ Object
Returns the value of attribute indent.
3 4 5 |
# File 'lib/rhtml/html.rb', line 3 def indent @indent end |
Instance Method Details
#raw!(string = '') ⇒ Object
43 44 45 |
# File 'lib/rhtml/html.rb', line 43 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 |
# File 'lib/rhtml/html.rb', line 11 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 self.content << Rhtml.tag_close(tag_name, indent) self end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/rhtml/html.rb', line 47 def to_s content end |