Class: Inversion::Template::CommentTag

Inherits:
Tag
  • Object
show all
Includes:
ContainerTag
Defined in:
lib/inversion/template/commenttag.rb

Overview

Inversion ‘comment’ tag.

This tag hides its contents from the rendered output.

Syntax

<?comment ?><?end?>
<?comment Disabled for now ?>
   <?attr some_hidden_attribute ?>
<?end comment ?>

Constant Summary

Constants inherited from Tag

Tag::TAG_PLUGIN_PATTERN

Instance Attribute Summary

Attributes included from ContainerTag

#subnodes

Attributes inherited from Tag

#body

Attributes inherited from Node

#colnum, #linenum

Instance Method Summary collapse

Methods included from ContainerTag

#<<, #initialize, #is_container?, #render_subnodes

Methods inherited from Tag

create, #derivatives, inherited, #initialize, load, load_all, #tagname, types, #types

Methods included from MethodUtilities

#singleton_attr_accessor, #singleton_attr_reader, #singleton_attr_writer

Methods included from AbstractClass

included

Methods included from AbstractClass::ClassMethods

#inherited, #pure_virtual

Methods inherited from Node

#after_appending, #after_rendering, #before_appending, #before_rendering, #initialize, #is_container?, #location

Instance Method Details

#as_comment_bodyObject

Render the tag as the body of a comment, suitable for template debugging.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/inversion/template/commenttag.rb', line 36

def as_comment_body
	firstnode, lastnode = self.subnodes.first, self.subnodes.last
	nodecount = self.subnodes.length

	linedesc = if firstnode.linenum == lastnode.linenum
			"on line %d" % [ firstnode.linenum ]
		else
			"from line %d to %d" % [ firstnode.linenum, lastnode.linenum ]
		end

	return "Commented out %d nodes %s%s" % [
		nodecount,
		linedesc,
		self.body.empty? ? '' : ': ' + self.body,
	]

end

#render(state) ⇒ Object

Render (or don’t render, actually) the comment’s subnodes.



29
30
31
# File 'lib/inversion/template/commenttag.rb', line 29

def render( state )
	return ''
end