Class: Inversion::Template::EndTag
- Defined in:
- lib/inversion/template/endtag.rb
Overview
Closing tag class
Constant Summary
Constants inherited from Tag
Instance Attribute Summary collapse
-
#opener ⇒ Object
readonly
The ContainerTag that this end tag closes.
Attributes inherited from Tag
Attributes inherited from Node
Instance Method Summary collapse
-
#as_comment_body ⇒ Object
Render the tag as the body of a comment, suitable for template debugging.
-
#before_appending(state) ⇒ Object
Parser callback – close the given ‘state`’s currently-open container node.
-
#initialize(body = '', linenum = nil, colnum = nil) ⇒ EndTag
constructor
Overridden to provide a default ‘body`.
Methods inherited from Tag
create, #derivatives, inherited, load, load_all, #tagname, types, #types
Methods included from MethodUtilities
#singleton_attr_accessor, #singleton_attr_reader, #singleton_attr_writer
Methods included from AbstractClass
Methods included from AbstractClass::ClassMethods
Methods inherited from Node
#after_appending, #after_rendering, #before_rendering, #is_container?, #location, #render
Constructor Details
#initialize(body = '', linenum = nil, colnum = nil) ⇒ EndTag
Overridden to provide a default ‘body`.
11 12 13 14 |
# File 'lib/inversion/template/endtag.rb', line 11 def initialize( body='', linenum=nil, colnum=nil ) super @opener = nil end |
Instance Attribute Details
#opener ⇒ Object (readonly)
The ContainerTag that this end tag closes
22 23 24 |
# File 'lib/inversion/template/endtag.rb', line 22 def opener @opener end |
Instance Method Details
#as_comment_body ⇒ Object
Render the tag as the body of a comment, suitable for template debugging.
47 48 49 |
# File 'lib/inversion/template/endtag.rb', line 47 def as_comment_body return "End of %s" % [ self.opener.as_comment_body ] end |
#before_appending(state) ⇒ Object
Parser callback – close the given ‘state`’s currently-open container node.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/inversion/template/endtag.rb', line 26 def before_appending( state ) @opener = state.pop self.log.debug "End tag for %s at %s" % [ @opener.tagname, @opener.location ] # If the end tag has a body, it should match the container that's just # been popped. if self.body && !self.body.empty? && self.body.downcase != @opener.tagname.downcase raise Inversion::ParseError, "unbalanced end: expected %p, got %p" % [ @opener.tagname.downcase, self.body.downcase, ] end super end |