Class: Arbre::Html::Comment
- Defined in:
- lib/arbre/html/comment.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
Instance Method Summary collapse
Methods inherited from Element
#+, #<<, #ancestors, #arbre_context, #assigns, #children, #content, #content=, #descendants, #empty?, #has_children?, #helpers, #indent_level, #initialize, #inspect, #orphan?, #parent, #parent=, #remove!, #respond_to?, #to_html
Methods included from Querying
#child_tags, #descendant_tags, #find, #find_by_classes, #find_by_id, #find_by_tag, #find_by_tag_and_classes, #find_first
Methods included from Element::Building
#append_within, #build, #current_element, #current_flow, included, #insert, #insert_child, #prepend_within, #temporary
Constructor Details
This class inherits a constructor from Arbre::Element
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Arbre::Element
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
7 8 9 |
# File 'lib/arbre/html/comment.rb', line 7 def comment @comment end |
Instance Method Details
#build!(comment = nil) ⇒ Object
9 10 11 |
# File 'lib/arbre/html/comment.rb', line 9 def build!(comment = nil) @comment = comment end |
#to_s ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/arbre/html/comment.rb', line 13 def to_s spaces = (' ' * indent_level * Tag::INDENT_SIZE) out = ActiveSupport::SafeBuffer.new if !comment out << '<!-- -->'.html_safe elsif comment.include?("\n") out << spaces << '<!--'.html_safe out << "\n" out << indent_comment out << "\n" out << spaces << '-->'.html_safe else out << '<!-- '.html_safe << comment << ' -->'.html_safe end out end |