Class: Arrow::Template::Directive

Inherits:
Node show all
Includes:
PluginFactory
Defined in:
lib/arrow/template/nodes.rb

Overview

The abstract directive superclass. Instances of derivatives of this class define template behaviour and content.

Constant Summary collapse

SVNRev =

SVN Revision

%q$Rev$
SVNId =

SVN Id

%q$Id$

Constants included from HTMLUtilities

HTMLUtilities::ARRAY_HTML_CONTAINER, HTMLUtilities::HASH_HTML_CONTAINER, HTMLUtilities::HASH_PAIR_HTML, HTMLUtilities::IMMEDIATE_OBJECT_HTML_CONTAINER, HTMLUtilities::IVAR_HTML_FRAGMENT, HTMLUtilities::OBJECT_HTML_CONTAINER, HTMLUtilities::THREAD_DUMP_KEY

Instance Attribute Summary

Attributes inherited from Node

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#add_to_template, #is_rendering_node?, #to_a, #to_s

Methods included from HTMLUtilities

escape_html, make_html_for_object, make_object_html_wrapper

Methods inherited from Object

deprecate_class_method, deprecate_method, inherited

Constructor Details

#initialize(type, parser, state) ⇒ Directive

Initialize a new Directive with the given type (the directive name), parser (Arrow::Template::Parser), and state (Arrow::Template::Parser::State object).



280
281
282
283
# File 'lib/arrow/template/nodes.rb', line 280

def initialize( type, parser, state )
	super( type )
	self.parse_directive_contents( parser, state )
end

Class Method Details

.create(tag, parser, state) ⇒ Object

Factory method: overridden from PluginFactory.create to pass the name into constructors for parsing context.



268
269
270
# File 'lib/arrow/template/nodes.rb', line 268

def self::create( tag, parser, state )
	super( tag, tag, parser, state )
end

.derivativeDirsObject

Return the list of subdirectories to search for template nodes.



261
262
263
# File 'lib/arrow/template/nodes.rb', line 261

def self::derivativeDirs
	["arrow/template"]
end

Instance Method Details

#inspectObject

Return a human-readable version of the object suitable for debugging messages.



302
303
304
# File 'lib/arrow/template/nodes.rb', line 302

def inspect
	%Q{<%s Directive>} % [ @type.capitalize ]
end

#render(template, scope) ⇒ Object

Render the directive as a String and return it.



291
292
293
294
295
296
297
# File 'lib/arrow/template/nodes.rb', line 291

def render( template, scope )
	rary = []
	rary << template.render_comment( self.inspect ) if
		template._config[:debuggingComments]

	return rary
end

#to_htmlObject

Return an HTML fragment that can be used to represent the node symbolically in a web-based introspection interface.



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/arrow/template/nodes.rb', line 309

def to_html

	if block_given?
		callback = Proc.new
		super( &callback )
	else
		fields = instance_variables.sort.collect {|ivar|
			val = instance_variable_get( ivar )
			%q{<span class="ivar"><em>%s:</em> %s</span>} %
				[ ivar, self.escape_html(val) ]
		}

		super { fields.join(", ") }
	end
end