Class: Inversion::Template::IncludeTag

Inherits:
Tag
  • Object
show all
Defined in:
lib/inversion/template/includetag.rb

Overview

Inversion ‘include’ tag.

A tag that inserts other template files into the current template.

Example

<?include /an/absolute/path/to/a/different/template.tmpl ?>
<?include a/relative/path/to/a/different/template.tmpl ?>

Constant Summary

Constants inherited from Tag

Tag::TAG_PLUGIN_PATTERN

Instance Attribute Summary collapse

Attributes inherited from Tag

#body

Attributes inherited from Node

#colnum, #linenum

Instance Method Summary collapse

Methods inherited from Tag

#as_comment_body, 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

included

Methods included from AbstractClass::ClassMethods

#inherited, #pure_virtual

Methods inherited from Node

#after_rendering, #as_comment_body, #before_rendering, #is_container?, #location, #render

Constructor Details

#initialize(path, linenum = nil, colnum = nil) ⇒ IncludeTag

Create a new IncludeTag with the specified ‘path`.



23
24
25
26
27
28
# File 'lib/inversion/template/includetag.rb', line 23

def initialize( path, linenum=nil, colnum=nil )
	super
	self.log.debug "Body is: %p" % [ @body ]
	@path = @body
	@included_template = nil
end

Instance Attribute Details

#pathObject (readonly)

The path of the included template



36
37
38
# File 'lib/inversion/template/includetag.rb', line 36

def path
  @path
end

Instance Method Details

#after_appending(parsestate) ⇒ Object

Parser callback – append the nodes from the included template onto the tree of the including template.



47
48
49
# File 'lib/inversion/template/includetag.rb', line 47

def after_appending( parsestate )
	parsestate.append_tree( @included_template.node_tree )
end

#before_appending(parsestate) ⇒ Object

Parser callback – Load the included template and check for recursive includes.



40
41
42
# File 'lib/inversion/template/includetag.rb', line 40

def before_appending( parsestate )
	@included_template = parsestate.load_subtemplate( self.path )
end