Class: NanDoc::Html::Tags
- Inherits:
-
Object
- Object
- NanDoc::Html::Tags
- Defined in:
- lib/nandoc/html/tags.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#current ⇒ Object
readonly
Returns the value of attribute current.
Instance Method Summary collapse
-
#initialize ⇒ Tags
constructor
A new instance of Tags.
- #push_raw(str) ⇒ Object
- #push_smart(name, classes, content) ⇒ Object
- #push_tag_now(name, classes, content) ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize ⇒ Tags
Returns a new instance of Tags.
4 5 6 7 |
# File 'lib/nandoc/html/tags.rb', line 4 def initialize @current = nil @content = [] end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
9 10 11 |
# File 'lib/nandoc/html/tags.rb', line 9 def content @content end |
#current ⇒ Object (readonly)
Returns the value of attribute current.
10 11 12 |
# File 'lib/nandoc/html/tags.rb', line 10 def current @current end |
Instance Method Details
#push_raw(str) ⇒ Object
12 13 14 15 |
# File 'lib/nandoc/html/tags.rb', line 12 def push_raw str flush if @current @content.push str end |
#push_smart(name, classes, content) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nandoc/html/tags.rb', line 17 def push_smart name, classes, content tag = normalize_tag(name, classes) if @current != tag flush if @current @current = tag @content.push render_open_tag(tag) end @content.push content nil end |
#push_tag_now(name, classes, content) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/nandoc/html/tags.rb', line 28 def push_tag_now name, classes, content tag = normalize_tag(name, classes) @content.push render_open_tag(tag) @content.push content @content.push render_close_tag(tag) nil end |
#to_html ⇒ Object
36 37 38 39 |
# File 'lib/nandoc/html/tags.rb', line 36 def to_html flush if @current @content.join('') end |