Class: Inversion::Template::TextNode
- Defined in:
- lib/inversion/template/textnode.rb
Overview
Inversion text node class – container for static content in templates between tags.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
The node body.
Attributes inherited from Node
Instance Method Summary collapse
-
#as_comment_body ⇒ Object
Render the text node as the body of a comment.
-
#initialize(body, linenum = nil, colnum = nil) ⇒ TextNode
constructor
Create a new TextNode with the specified ‘source`.
-
#render(renderstate) ⇒ Object
Render the node.
Methods inherited from Node
#after_appending, #after_rendering, #before_appending, #before_rendering, #is_container?, #location
Methods included from AbstractClass
Methods included from AbstractClass::ClassMethods
Constructor Details
#initialize(body, linenum = nil, colnum = nil) ⇒ TextNode
Create a new TextNode with the specified ‘source`.
11 12 13 14 |
# File 'lib/inversion/template/textnode.rb', line 11 def initialize( body, linenum=nil, colnum=nil ) @body = body super end |
Instance Attribute Details
#body ⇒ Object (readonly)
The node body
22 23 24 |
# File 'lib/inversion/template/textnode.rb', line 22 def body @body end |
Instance Method Details
#as_comment_body ⇒ Object
Render the text node as the body of a comment.
35 36 37 38 39 |
# File 'lib/inversion/template/textnode.rb', line 35 def as_comment_body comment_body = self.body[0,40].dump comment_body[-1,0] = '...' unless comment_body == self.body.dump return "Text (%d bytes): %s" % [ self.body.length, comment_body ] end |
#render(renderstate) ⇒ Object
Render the node.
26 27 28 29 30 31 |
# File 'lib/inversion/template/textnode.rb', line 26 def render( renderstate ) body = self.body.dup body.sub!( /\A\r?\n/, '' ) if renderstate && renderstate.[:strip_tag_lines] return body end |