Subversion Info

Rev
440
Last Checked In
2008-04-16 14:59:26 (13 hours ago)
Checked in by
deveiant

Parent

Class Index

Quicksearch

Arrow::Template

The default template class for Arrow.

Constants

SVNRev
SVN Revision
SVNId
SVN Id
Defaults
Configuration defaults. Valid members are the same as those listed for the config item of the #new method.
DefaultRenderers
A Hash which specifies the default renderers for different classes of objects.

Attributes

load_path[RW]

(Not documented)

Public Class Methods

attr_underbarred_accessor( sym ) click to toggle source

Create an attr_accessor method for the specified sym, but one which will look for instance variables with any leading underbars removed.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 273
273:     def self::attr_underbarred_accessor( sym )
274:         ivarname = '@' + sym.to_s.gsub( /^_+/, '' )
275:         define_method( sym ) {
276:             self.instance_variable_get( ivarname )
277:         }
278:         define_method( "#{sym}=" ) {|arg|
279:             self.instance_variable_set( ivarname, arg )
280:         }
281:     end
attr_underbarred_reader( sym ) click to toggle source

Create an attr_reader method for the specified sym, but one which will look for instance variables with any leading underbars removed.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 263
263:     def self::attr_underbarred_reader( sym )
264:         ivarname = '@' + sym.to_s.gsub( /^_+/, '' )
265:         define_method( sym ) {
266:             self.instance_variable_get( ivarname )
267:         }
268:     end
find_file( file, path=[] ) click to toggle source

Find the specified file in the given path (or the Template class‘s #load_path if not specified).

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 237
237:     def self::find_file( file, path=[] )
238:         raise TemplateError, "Filename #{file} is tainted." if
239:             file.tainted?
240: 
241:         filename = nil
242:         path.collect {|dir| File.expand_path(file, dir).untaint }.each do |fn|
243:             Arrow::Logger[self].debug "Checking path %p" % [ fn ]
244:             if File.file?( fn )
245:                 Arrow::Logger[self].debug "  found the template file at %p" % [ fn ]
246:                 filename = fn
247:                 break
248:             end
249:             
250:             Arrow::Logger[self].debug "  %p does not exist or is not a plain file." % [ fn ]
251:         end
252:         
253:         raise Arrow::TemplateError,
254:             "Template '%s' not found. Search path was %p" %
255:             [ file, path ] unless filename
256: 
257:         return filename
258:     end
load( name, path=[] ) click to toggle source

Load a template from a file.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 209
209:     def self::load( name, path=[] )
210: 
211:         # Find the file on either the specified or default path
212:         path = self.load_path if path.empty?
213:         Arrow::Logger[self].debug "Searching for template '%s' in %d directories" %
214:           [ name, path.size ]
215:         filename = self.find_file( name, path )
216:         Arrow::Logger[self].debug "Found '%s'" % [ filename ]
217: 
218:         # Read the template source
219:         source = File.read( filename )
220:         source.untaint
221: 
222:         # Create a new template object, set its path and filename, then tell it
223:         # to parse the loaded source to define its behaviour. Parse is called
224:         # after the file and path are set so directives in the template can
225:         # use them.
226:         obj = new()
227:         obj._file = filename
228:         obj._load_path.replace( path )
229:         obj.parse( source )
230: 
231:         return obj
232:     end
new( content=nil, config={} ) click to toggle source

Create a new template object with the specified content (a String) and config hash. The config can contain one or more of the following keys:

:parserClass
The class object that will be instantiated to parse the template text into nodes. Defaults to Arrow::Template::Parser.
:elideDirectiveLines
If set to a true value, lines of the template which contain only whitespace and one or more non-rendering directives will be discarded from the rendered output.
:debuggingComments
If set to a true value, nodes which are set up to do so will insert a comment with debugging information immediately before their rendered output.
:commentStart
The String which will be prepended to all comments rendered in the output. See #render_comment.
:commentEnd
The String which will be appended to all comments rendered in the output. See #render_comment.
:strictAttributes
If set to a true value, method calls which don‘t match already-extant attributes will result in NameErrors. This is false by default, which causes method calls to generate attributes with the same name.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 314
314:     def initialize( content=nil, config={} )
315:         @config = Defaults.merge( config, &Arrow::HashMergeFunction )
316:         @renderers = DefaultRenderers.dup
317:         @attributes = {}
318:         @syntax_tree = []
319:         @source = content
320:         @file = nil
321:         @creation_time = Time.now
322:         @load_path = self.class.load_path.dup
323:         @prerender_done = false
324:         @postrender_done = false
325: 
326:         @enclosing_templates = []
327: 
328:         case content
329:         when String
330:             self.parse( content )
331:         when Array
332:             self.install_syntax_tree( content )
333:         when NilClass
334:             # No-op
335:         else
336:             raise TemplateError,
337:                 "Can't handle a %s as template content" % content.class.name
338:         end
339:     end

Public Instance Methods

_enclosing_template() click to toggle source

Return the template that is enclosing the receiver in the current context, if any.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 394
394:     def _enclosing_template
395:         self._enclosing_templates.last
396:     end
after_rendering( enclosing_template=nil ) click to toggle source

Alias for #postrender

before_rendering( enclosing_template=nil ) click to toggle source

Alias for #prerender

changed?() click to toggle source

Returns true if the source file from which the template was read has been modified since the receiver was instantiated. Always returns false if the template wasn‘t loaded from a file.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 457
457:     def changed?
458:         return false unless @file
459: 
460:         if File.exists?( @file )
461:             self.log.debug "Comparing creation time '%s' with file mtime '%s'" %
462:                 [ @creation_time, File.mtime(@file) ]
463:             rval = File.mtime( @file ) > @creation_time
464:         end
465: 
466:         self.log.debug "Template file '%s' has %s" %
467:             [ @file, rval ? "changed" : "not changed" ]
468:         return rval
469:     end
initialize_copy( original ) click to toggle source

Initialize a copy of the original template object.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 343
343:     def initialize_copy( original )
344:         super
345:         
346:         @attributes = {}
347:         tree = original._syntax_tree.collect {|node| node.clone}
348:         self.install_syntax_tree( tree )
349:     end
inspect() click to toggle source

Return a human-readable representation of the template object.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 400
400:     def inspect
401:         "#<%s:0x%0x %s (%d nodes)>" % [
402:             self.class.name,
403:             self.object_id * 2,
404:             @file ? @file : '(anonymous)',
405:             @syntax_tree.length,
406:         ]
407:     end
install_node( node ) click to toggle source

Install the given node into the template object.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 438
438:     def install_node( node )
439:         #self.log.debug "Installing a %s %p" % [node.type, node]
440: 
441:         if node.respond_to?( :name ) && node.name
442:             unless @attributes.key?( node.name )
443:                 #self.log.debug "Installing an attribute for a node named %p" % node.name
444:                 @attributes[ node.name ] = nil
445:                 self.add_attribute_accessor( node.name.intern )
446:                 self.add_attribute_mutator( node.name.intern )
447:             else
448:                 #self.log.debug "Already have a attribute named %p" % node.name
449:             end
450:         end
451:     end
install_syntax_tree( tree ) click to toggle source

Install a new syntax tree in the template object, replacing the old one, if any.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 431
431:     def install_syntax_tree( tree )
432:         @syntax_tree = tree
433:         @syntax_tree.each do |node| node.add_to_template(self) end
434:     end
make_rendering_scope() click to toggle source

Create an anonymous module to act as a scope for any evals that take place during a single render.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 545
545:     def make_rendering_scope
546:         # self.log.debug "Making rendering scope with attributes: %p" % [@attributes]
547:         scope = RenderingScope.new( @attributes )
548:         return scope
549:     end
memsize() click to toggle source

Return the approximate size of the template, in bytes. Used by Arrow::Cache for size thresholds.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 412
412:     def memsize
413:         @source ? @source.length : 0
414:     end
parse( source ) click to toggle source

Parse the given template source (a String) and put the resulting nodes into the template‘s syntax_tree.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 419
419:     def parse( source )
420:         @source = source
421:         parserClass = @config[:parserClass]
422:         tree = parserClass.new( @config ).parse( source, self )
423: 
424:         #self.log.debug "Parse complete: syntax tree is: %p" % tree
425:         return self.install_syntax_tree( tree )
426:     end
postrender( enclosing_template=nil ) click to toggle source

Clean up after template rendering, calling each of its nodes’ #after_rendering hook.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 532
532:     def postrender( enclosing_template=nil )
533:         @syntax_tree.each do |node|
534:             # self.log.debug "    post-rendering %p" % [node]
535:             node.after_rendering( self ) if
536:                 node.respond_to?( :after_rendering )
537:         end
538:         @enclosing_templates.pop
539:     end
Also aliased as: after_rendering
postrender_done?() click to toggle source

Returns true if this template has already been through a post-render.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 525
525:     def postrender_done?
526:         return @postrender_done
527:     end
prerender( enclosing_template=nil ) click to toggle source

Prep the template for rendering, calling each of its nodes’ #before_rendering hook.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 480
480:     def prerender( enclosing_template=nil )
481:         @enclosing_templates << enclosing_template
482: 
483:         @syntax_tree.each do |node|
484:             # self.log.debug "    pre-rendering %p" % [node]
485:             node.before_rendering( self ) if
486:                 node.respond_to?( :before_rendering )
487:         end
488:     end
Also aliased as: before_rendering
prerender_done?() click to toggle source

Returns true if this template has already been through a pre-render.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 473
473:     def prerender_done?
474:         return @prerender_done
475:     end
render( nodes=nil, scope=nil, enclosing_template=nil ) click to toggle source

Render the template to text and return it as a String. If called with an Array of nodes, the template will render them instead of its own syntax_tree. If given a scope (a Module object), a Binding of its internal state it will be used as the context of evaluation for the render. If not specified, a new anonymous Module instance is created for the render. If a enclosing_template is given, make it available during rendering for variable-sharing, etc. Returns the results of each nodes’ render joined together with the default string separator (+$,+).

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 500
500:     def render( nodes=nil, scope=nil, enclosing_template=nil )
501:         rval = []
502:         nodes ||= self.get_prepped_nodes
503:         scope ||= self.make_rendering_scope
504:         
505:         self.prerender( enclosing_template )
506: 
507:         # Render each node
508:         nodes.each do |node|
509:             # self.log.debug "  rendering %p" % [ node ]
510:             begin
511:                 rval << node.render( self, scope )
512:             rescue ::Exception => err
513:                 rval << err
514:             end
515:         end
516: 
517:         return self.render_objects( *rval )
518:     ensure
519:         self.postrender
520:     end
Also aliased as: to_s
render_comment( message ) click to toggle source

Render the given message as a comment as specified by the template configuration.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 584
584:     def render_comment( message )
585:         comment = "%s%s%s\n" % [
586:             @config[:commentStart],
587:             message,
588:             @config[:commentEnd],
589:         ]
590:         #self.log.debug "Rendered comment: %s" % comment
591:         return comment
592:     end
render_objects( *objs ) click to toggle source

Render the specified objects into text.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 553
553:     def render_objects( *objs )
554:         objs.collect do |obj|
555:             rval = nil
556:             key = (@renderers.keys & obj.class.ancestors).sort {|a,b| a <=> b}.first
557: 
558:             begin
559:                 if key
560:                     case @renderers[ key ]
561:                     when Proc, Method
562:                         rval = @renderers[ key ].call( obj, self )
563:                     when Symbol
564:                         methodname = @renderers[ key ]
565:                         rval = obj.send( methodname )
566:                     else
567:                         raise TypeError, "Unknown renderer type '%s' for %p" %
568:                             [ @renderers[key], obj ]
569:                     end
570:                 else
571:                     rval = obj.to_s
572:                 end
573:             rescue => err
574:                 self.log.error "rendering error while rendering %p (a %s): %s" % 
575:                     [obj, obj.class.name, err.message]
576:                 @renderers[ ::Exception ].call( err, self )
577:             end
578:         end.join
579:     end
to_s( nodes=nil, scope=nil, enclosing_template=nil ) click to toggle source

Alias for #render

with_overridden_attributes( scope, hash ) {|self| ...} click to toggle source

Call the given block, overriding the contents of the template‘s attributes and the definitions in the specified scope with those from the pairs in the given hash.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 598
598:     def with_overridden_attributes( scope, hash )
599:         oldvals = {}
600:         begin
601:             hash.each do |name, value|
602:                 #self.log.debug "Overriding attribute %s with value: %p" %
603:                 #   [ name, value ]
604:                 oldvals[name] = @attributes.key?( name ) ? @attributes[ name ] : nil
605:                 @attributes[ name ] = value
606:             end
607:             scope.override( hash ) do
608:                 yield( self )
609:             end
610:         ensure
611:             oldvals.each do |name, value|
612:                 #self.log.debug "Restoring old value: %s for attribute %p" %
613:                 #   [ name, value ]
614:                 @attributes.delete( name )
615:                 @attributes[ name ] = oldvals[name] if oldvals[name]
616:             end
617:         end
618:     end

Protected Instance Methods

add_attribute_accessor( sym ) click to toggle source

Add a singleton accessor (getter) method for accessing the attribute specified by sym to the receiver.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 698
698:     def add_attribute_accessor( sym )
699:         name = sym.to_s.sub( /=$/, '' )
700: 
701:         code = %Q{
702:             def self::#{name}
703:                 @attributes[#{name.inspect}]
704:             end
705:         }
706: 
707:         # $stderr.puts "Auto-defining accessor for #{name}: #{code}"
708:         eval( code, nil, "#{name} [Auto-defined]", __LINE__ )
709:     end
add_attribute_mutator( sym ) click to toggle source

Add a singleton mutator (setter) method for accessing the attribute specified by sym to the receiver.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 714
714:     def add_attribute_mutator( sym )
715:         name = sym.to_s.sub( /=$/, '' )
716: 
717:         code = %Q{
718:             def self::#{name}=( arg )
719:                 @attributes[ #{name.inspect} ] = arg
720:             end
721:         }
722: 
723:         # $stderr.puts "Auto-defining mutator for #{name}: #{code}"
724:         eval( code, nil, "#{name}= [Auto-defined]", __LINE__ )
725:     end
get_prepped_nodes() click to toggle source

Returns the syntax tree with its nodes prerendered in accordance with the template‘s configuration.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 628
628:     def get_prepped_nodes
629:         tree = @syntax_tree.dup
630: 
631:         self.strip_directive_whitespace( tree ) if
632:           @config[:elideDirectiveLines]
633: 
634:         return tree
635:     end
method_missing( sym, *args, &block ) click to toggle source

Autoload accessor/mutator methods for attributes.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 674
674:     def method_missing( sym, *args, &block )
675:         name = sym.to_s.gsub( /=$/, '' )
676:         super unless @attributes.key?( name ) || !@config[:strictAttributes]
677: 
678:         #self.log.debug "Autoloading for #{sym}"
679: 
680:         # Mutator
681:         if /=$/ =~ sym.to_s
682:             #self.log.debug "Autoloading mutator %p" % sym
683:             self.add_attribute_mutator( sym )
684:         # Accessor
685:         else
686:             #self.log.debug "Autoloading accessor %p" % sym
687:             self.add_attribute_accessor( sym )
688:         end
689: 
690:         # Don't use #send to avoid infinite recursion in case method
691:         # definition has failed for some reason.
692:         self.method( sym ).call( *args )
693:     end
strip_directive_whitespace( tree ) click to toggle source

Strip whitespace from the tails of textnodes before and the head of textnodes after lines consisting only of non-rendering directives in the given template syntax tree.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 641
641:     def strip_directive_whitespace( tree )
642:         # Make a flat list of all nodes
643:         nodes = tree.collect {|node| node.to_a}.flatten
644: 
645:         # Elide non-rendering directive lines. Match node lists like:
646:         #   <TextNode> =~ /\n\s*$/
647:         #   <NonRenderingNode>*
648:         #   <TextNode> =~ /^\n/
649:         # removing one "\n" from the tail of the leading textnode and the
650:         # head of the trailing textnode. Trailing textnode can also be a
651:         # leading textnode for another series.
652:         nodes.each_with_index do |node,i|
653:             leadingNode = nodes[i-1]
654: 
655:             # If both the leading node and the current one match the
656:             # criteria, look for a trailing node.
657:             if i.nonzero? && leadingNode.is_a?( TextNode ) &&
658:                     leadingNode =~ /\n\s*$/s
659: 
660:                 # Find the trailing node. Abandon the search on any
661:                 # rendering directive or text node that includes a blank line.
662:                 trailingNode = nodes[i..-1].find do |node|
663:                     break nil if node.rendering?
664:                     node.is_a?( TextNode ) && node =~ /^\n/
665:                 end
666: 
667:                 leadingNode.body.sub!( /\n\s*$/, '' ) if trailingNode
668:             end
669:         end
670:     end

secsequence

--- SEC00151

seccomment

--- ""

classlist

--- |
Module <a href="Template/ConditionalDirective.html" class="link">Arrow::Template::ConditionalDirective</a><br />
Class <a href="Template/AttributeDirective.html" class="link">Arrow::Template::AttributeDirective</a><br />
Class <a href="Template/BracketingDirective.html" class="link">Arrow::Template::BracketingDirective</a><br />
Class <a href="Template/CommentNode.html" class="link">Arrow::Template::CommentNode</a><br />
Class <a href="Template/Directive.html" class="link">Arrow::Template::Directive</a><br />
Class <a href="Template/Node.html" class="link">Arrow::Template::Node</a><br />
Class <a href="Template/RenderingScope.html" class="link">Arrow::Template::RenderingScope</a><br />
Class <a href="Template/TextNode.html" class="link">Arrow::Template::TextNode</a><br />

attributes

--- 
- name: load_path
  rw: RW
  a_desc: ""

method_list

--- 
- methods: 
  - visibility: public
    aref: M000447
    name: attr_underbarred_accessor
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 273</span>\n\
      273:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">attr_underbarred_accessor</span>( <span class=\"ruby-identifier\">sym</span> )\n\
      274:         <span class=\"ruby-identifier\">ivarname</span> = <span class=\"ruby-value str\">'@'</span> <span class=\"ruby-operator\">+</span> <span class=\"ruby-identifier\">sym</span>.<span class=\"ruby-identifier\">to_s</span>.<span class=\"ruby-identifier\">gsub</span>( <span class=\"ruby-regexp re\">/^_+/</span>, <span class=\"ruby-value str\">''</span> )\n\
      275:         <span class=\"ruby-identifier\">define_method</span>( <span class=\"ruby-identifier\">sym</span> ) {\n\
      276:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">instance_variable_get</span>( <span class=\"ruby-identifier\">ivarname</span> )\n\
      277:         }\n\
      278:         <span class=\"ruby-identifier\">define_method</span>( <span class=\"ruby-node\">&quot;#{sym}=&quot;</span> ) {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">arg</span><span class=\"ruby-operator\">|</span>\n\
      279:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">instance_variable_set</span>( <span class=\"ruby-identifier\">ivarname</span>, <span class=\"ruby-identifier\">arg</span> )\n\
      280:         }\n\
      281:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create an attr_accessor method for the specified <tt>sym</tt>, but one
      which will look for instance variables with any leading underbars removed.
      </p>
    params: ( sym )
  - visibility: public
    aref: M000446
    name: attr_underbarred_reader
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 263</span>\n\
      263:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">attr_underbarred_reader</span>( <span class=\"ruby-identifier\">sym</span> )\n\
      264:         <span class=\"ruby-identifier\">ivarname</span> = <span class=\"ruby-value str\">'@'</span> <span class=\"ruby-operator\">+</span> <span class=\"ruby-identifier\">sym</span>.<span class=\"ruby-identifier\">to_s</span>.<span class=\"ruby-identifier\">gsub</span>( <span class=\"ruby-regexp re\">/^_+/</span>, <span class=\"ruby-value str\">''</span> )\n\
      265:         <span class=\"ruby-identifier\">define_method</span>( <span class=\"ruby-identifier\">sym</span> ) {\n\
      266:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">instance_variable_get</span>( <span class=\"ruby-identifier\">ivarname</span> )\n\
      267:         }\n\
      268:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create an attr_reader method for the specified <tt>sym</tt>, but one which
      will look for instance variables with any leading underbars removed.
      </p>
    params: ( sym )
  - visibility: public
    aref: M000445
    name: find_file
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 237</span>\n\
      237:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">find_file</span>( <span class=\"ruby-identifier\">file</span>, <span class=\"ruby-identifier\">path</span>=[] )\n\
      238:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">TemplateError</span>, <span class=\"ruby-node\">&quot;Filename #{file} is tainted.&quot;</span> <span class=\"ruby-keyword kw\">if</span>\n\
      239:             <span class=\"ruby-identifier\">file</span>.<span class=\"ruby-identifier\">tainted?</span>\n\
      240: \n\
      241:         <span class=\"ruby-identifier\">filename</span> = <span class=\"ruby-keyword kw\">nil</span>\n\
      242:         <span class=\"ruby-identifier\">path</span>.<span class=\"ruby-identifier\">collect</span> {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">dir</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-constant\">File</span>.<span class=\"ruby-identifier\">expand_path</span>(<span class=\"ruby-identifier\">file</span>, <span class=\"ruby-identifier\">dir</span>).<span class=\"ruby-identifier\">untaint</span> }.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">fn</span><span class=\"ruby-operator\">|</span>\n\
      243:             <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;Checking path %p&quot;</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-identifier\">fn</span> ]\n\
      244:             <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-constant\">File</span>.<span class=\"ruby-identifier\">file?</span>( <span class=\"ruby-identifier\">fn</span> )\n\
      245:                 <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;  found the template file at %p&quot;</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-identifier\">fn</span> ]\n\
      246:                 <span class=\"ruby-identifier\">filename</span> = <span class=\"ruby-identifier\">fn</span>\n\
      247:                 <span class=\"ruby-keyword kw\">break</span>\n\
      248:             <span class=\"ruby-keyword kw\">end</span>\n\
      249:             \n\
      250:             <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;  %p does not exist or is not a plain file.&quot;</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-identifier\">fn</span> ]\n\
      251:         <span class=\"ruby-keyword kw\">end</span>\n\
      252:         \n\
      253:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">TemplateError</span>,\n\
      254:             <span class=\"ruby-value str\">&quot;Template '%s' not found. Search path was %p&quot;</span> <span class=\"ruby-operator\">%</span>\n\
      255:             [ <span class=\"ruby-identifier\">file</span>, <span class=\"ruby-identifier\">path</span> ] <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">filename</span>\n\
      256: \n\
      257:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">filename</span>\n\
      258:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Find the specified <tt>file</tt> in the given <tt>path</tt> (or the <a
      href="Template.html">Template</a> class&#8216;s #load_path if not
      specified).
      </p>
    params: ( file, path=[] )
  - visibility: public
    aref: M000444
    name: load
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 209</span>\n\
      209:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">load</span>( <span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">path</span>=[] )\n\
      210: \n\
      211:         <span class=\"ruby-comment cmt\"># Find the file on either the specified or default path</span>\n\
      212:         <span class=\"ruby-identifier\">path</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">load_path</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">path</span>.<span class=\"ruby-identifier\">empty?</span>\n\
      213:         <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;Searching for template '%s' in %d directories&quot;</span> <span class=\"ruby-operator\">%</span>\n\
      214:           [ <span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">path</span>.<span class=\"ruby-identifier\">size</span> ]\n\
      215:         <span class=\"ruby-identifier\">filename</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">find_file</span>( <span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">path</span> )\n\
      216:         <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;Found '%s'&quot;</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-identifier\">filename</span> ]\n\
      217: \n\
      218:         <span class=\"ruby-comment cmt\"># Read the template source</span>\n\
      219:         <span class=\"ruby-identifier\">source</span> = <span class=\"ruby-constant\">File</span>.<span class=\"ruby-identifier\">read</span>( <span class=\"ruby-identifier\">filename</span> )\n\
      220:         <span class=\"ruby-identifier\">source</span>.<span class=\"ruby-identifier\">untaint</span>\n\
      221: \n\
      222:         <span class=\"ruby-comment cmt\"># Create a new template object, set its path and filename, then tell it</span>\n\
      223:         <span class=\"ruby-comment cmt\"># to parse the loaded source to define its behaviour. Parse is called</span>\n\
      224:         <span class=\"ruby-comment cmt\"># after the file and path are set so directives in the template can</span>\n\
      225:         <span class=\"ruby-comment cmt\"># use them.</span>\n\
      226:         <span class=\"ruby-identifier\">obj</span> = <span class=\"ruby-identifier\">new</span>()\n\
      227:         <span class=\"ruby-identifier\">obj</span>.<span class=\"ruby-identifier\">_file</span> = <span class=\"ruby-identifier\">filename</span>\n\
      228:         <span class=\"ruby-identifier\">obj</span>.<span class=\"ruby-identifier\">_load_path</span>.<span class=\"ruby-identifier\">replace</span>( <span class=\"ruby-identifier\">path</span> )\n\
      229:         <span class=\"ruby-identifier\">obj</span>.<span class=\"ruby-identifier\">parse</span>( <span class=\"ruby-identifier\">source</span> )\n\
      230: \n\
      231:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">obj</span>\n\
      232:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Load a template from a file.
      </p>
    params: ( name, path=[] )
  - visibility: public
    aref: M000448
    name: new
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 314</span>\n\
      314:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize</span>( <span class=\"ruby-identifier\">content</span>=<span class=\"ruby-keyword kw\">nil</span>, <span class=\"ruby-identifier\">config</span>={} )\n\
      315:         <span class=\"ruby-ivar\">@config</span> = <span class=\"ruby-constant\">Defaults</span>.<span class=\"ruby-identifier\">merge</span>( <span class=\"ruby-identifier\">config</span>, <span class=\"ruby-operator\">&amp;</span><span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">HashMergeFunction</span> )\n\
      316:         <span class=\"ruby-ivar\">@renderers</span> = <span class=\"ruby-constant\">DefaultRenderers</span>.<span class=\"ruby-identifier\">dup</span>\n\
      317:         <span class=\"ruby-ivar\">@attributes</span> = {}\n\
      318:         <span class=\"ruby-ivar\">@syntax_tree</span> = []\n\
      319:         <span class=\"ruby-ivar\">@source</span> = <span class=\"ruby-identifier\">content</span>\n\
      320:         <span class=\"ruby-ivar\">@file</span> = <span class=\"ruby-keyword kw\">nil</span>\n\
      321:         <span class=\"ruby-ivar\">@creation_time</span> = <span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">now</span>\n\
      322:         <span class=\"ruby-ivar\">@load_path</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">load_path</span>.<span class=\"ruby-identifier\">dup</span>\n\
      323:         <span class=\"ruby-ivar\">@prerender_done</span> = <span class=\"ruby-keyword kw\">false</span>\n\
      324:         <span class=\"ruby-ivar\">@postrender_done</span> = <span class=\"ruby-keyword kw\">false</span>\n\
      325: \n\
      326:         <span class=\"ruby-ivar\">@enclosing_templates</span> = []\n\
      327: \n\
      328:         <span class=\"ruby-keyword kw\">case</span> <span class=\"ruby-identifier\">content</span>\n\
      329:         <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-constant\">String</span>\n\
      330:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">parse</span>( <span class=\"ruby-identifier\">content</span> )\n\
      331:         <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-constant\">Array</span>\n\
      332:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">install_syntax_tree</span>( <span class=\"ruby-identifier\">content</span> )\n\
      333:         <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-constant\">NilClass</span>\n\
      334:             <span class=\"ruby-comment cmt\"># No-op</span>\n\
      335:         <span class=\"ruby-keyword kw\">else</span>\n\
      336:             <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">TemplateError</span>,\n\
      337:                 <span class=\"ruby-value str\">&quot;Can't handle a %s as template content&quot;</span> <span class=\"ruby-operator\">%</span> <span class=\"ruby-identifier\">content</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">name</span>\n\
      338:         <span class=\"ruby-keyword kw\">end</span>\n\
      339:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create a <a href="Template.html#M000448">new</a> template object with the
      specified <tt>content</tt> (a String) and <tt>config</tt> hash. The
      <tt>config</tt> can contain one or more of the following keys:
      </p>
      <dl>
      <dt><b>:parserClass</b></dt><dd>The class object that will be instantiated to <a
      href="Template.html#M000453">parse</a> the template text into nodes.
      Defaults to <a href="Template/Parser.html">Arrow::Template::Parser</a>.
      
      </dd>
      <dt><b>:elideDirectiveLines</b></dt><dd>If set to a <tt>true</tt> value, lines of the template which contain only
      whitespace and one or more non-rendering directives will be discarded from
      the rendered output.
      
      </dd>
      <dt><b>:debuggingComments</b></dt><dd>If set to a <tt>true</tt> value, nodes which are set up to do so will
      insert a comment with debugging information immediately before their
      rendered output.
      
      </dd>
      <dt><b>:commentStart</b></dt><dd>The String which will be prepended to all comments rendered in the output.
      See <a href="Template.html#M000467">#render_comment</a>.
      
      </dd>
      <dt><b>:commentEnd</b></dt><dd>The String which will be appended to all comments rendered in the output.
      See <a href="Template.html#M000467">#render_comment</a>.
      
      </dd>
      <dt><b>:strictAttributes</b></dt><dd>If set to a <tt>true</tt> value, method calls which don&#8216;t match
      already-extant attributes will result in NameErrors. This is <tt>false</tt>
      by default, which causes method calls to generate attributes with the same
      name.
      
      </dd>
      </dl>
    params: ( content=nil, config={} )
  category: Class
  type: Public
- methods: 
  - visibility: public
    aref: M000450
    name: _enclosing_template
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 394</span>\n\
      394:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">_enclosing_template</span>\n\
      395:         <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">_enclosing_templates</span>.<span class=\"ruby-identifier\">last</span>\n\
      396:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Return the template that is enclosing the receiver in the current context,
      if any.
      </p>
    params: ()
  - visibility: public
    aref: M000464
    name: after_rendering
    m_desc: |-
      <p>
      Alias for <a href="Template.html#M000463">#postrender</a>
      </p>
    params: ( enclosing_template=nil )
  - visibility: public
    aref: M000459
    name: before_rendering
    m_desc: |-
      <p>
      Alias for <a href="Template.html#M000458">#prerender</a>
      </p>
    params: ( enclosing_template=nil )
  - visibility: public
    aref: M000456
    name: changed?
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 457</span>\n\
      457:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">changed?</span>\n\
      458:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">false</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-ivar\">@file</span>\n\
      459: \n\
      460:         <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-constant\">File</span>.<span class=\"ruby-identifier\">exists?</span>( <span class=\"ruby-ivar\">@file</span> )\n\
      461:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;Comparing creation time '%s' with file mtime '%s'&quot;</span> <span class=\"ruby-operator\">%</span>\n\
      462:                 [ <span class=\"ruby-ivar\">@creation_time</span>, <span class=\"ruby-constant\">File</span>.<span class=\"ruby-identifier\">mtime</span>(<span class=\"ruby-ivar\">@file</span>) ]\n\
      463:             <span class=\"ruby-identifier\">rval</span> = <span class=\"ruby-constant\">File</span>.<span class=\"ruby-identifier\">mtime</span>( <span class=\"ruby-ivar\">@file</span> ) <span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-ivar\">@creation_time</span>\n\
      464:         <span class=\"ruby-keyword kw\">end</span>\n\
      465: \n\
      466:         <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;Template file '%s' has %s&quot;</span> <span class=\"ruby-operator\">%</span>\n\
      467:             [ <span class=\"ruby-ivar\">@file</span>, <span class=\"ruby-identifier\">rval</span> <span class=\"ruby-value\">? </span><span class=\"ruby-value str\">&quot;changed&quot;</span> <span class=\"ruby-operator\">:</span> <span class=\"ruby-value str\">&quot;not changed&quot;</span> ]\n\
      468:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">rval</span>\n\
      469:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Returns <tt>true</tt> if the source file from which the template was read
      has been modified since the receiver was instantiated. Always returns
      <tt>false</tt> if the template wasn&#8216;t loaded from a file.
      </p>
    params: ()
  - visibility: public
    aref: M000449
    name: initialize_copy
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 343</span>\n\
      343:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize_copy</span>( <span class=\"ruby-identifier\">original</span> )\n\
      344:         <span class=\"ruby-keyword kw\">super</span>\n\
      345:         \n\
      346:         <span class=\"ruby-ivar\">@attributes</span> = {}\n\
      347:         <span class=\"ruby-identifier\">tree</span> = <span class=\"ruby-identifier\">original</span>.<span class=\"ruby-identifier\">_syntax_tree</span>.<span class=\"ruby-identifier\">collect</span> {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">node</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">clone</span>}\n\
      348:         <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">install_syntax_tree</span>( <span class=\"ruby-identifier\">tree</span> )\n\
      349:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Initialize a copy of the <tt>original</tt> template object.
      </p>
    params: ( original )
  - visibility: public
    aref: M000451
    name: inspect
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 400</span>\n\
      400:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">inspect</span>\n\
      401:         <span class=\"ruby-value str\">&quot;#&lt;%s:0x%0x %s (%d nodes)&gt;&quot;</span> <span class=\"ruby-operator\">%</span> [\n\
      402:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">name</span>,\n\
      403:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">object_id</span> <span class=\"ruby-operator\">*</span> <span class=\"ruby-value\">2</span>,\n\
      404:             <span class=\"ruby-ivar\">@file</span> <span class=\"ruby-operator\">?</span> <span class=\"ruby-ivar\">@file</span> <span class=\"ruby-operator\">:</span> <span class=\"ruby-value str\">'(anonymous)'</span>,\n\
      405:             <span class=\"ruby-ivar\">@syntax_tree</span>.<span class=\"ruby-identifier\">length</span>,\n\
      406:         ]\n\
      407:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Return a human-readable representation of the template object.
      </p>
    params: ()
  - visibility: public
    aref: M000455
    name: install_node
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 438</span>\n\
      438:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">install_node</span>( <span class=\"ruby-identifier\">node</span> )\n\
      439:         <span class=\"ruby-comment cmt\">#self.log.debug &quot;Installing a %s %p&quot; % [node.type, node]</span>\n\
      440: \n\
      441:         <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">respond_to?</span>( <span class=\"ruby-identifier\">:name</span> ) <span class=\"ruby-operator\">&amp;&amp;</span> <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">name</span>\n\
      442:             <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-ivar\">@attributes</span>.<span class=\"ruby-identifier\">key?</span>( <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">name</span> )\n\
      443:                 <span class=\"ruby-comment cmt\">#self.log.debug &quot;Installing an attribute for a node named %p&quot; % node.name</span>\n\
      444:                 <span class=\"ruby-ivar\">@attributes</span>[ <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">name</span> ] = <span class=\"ruby-keyword kw\">nil</span>\n\
      445:                 <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">add_attribute_accessor</span>( <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">name</span>.<span class=\"ruby-identifier\">intern</span> )\n\
      446:                 <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">add_attribute_mutator</span>( <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">name</span>.<span class=\"ruby-identifier\">intern</span> )\n\
      447:             <span class=\"ruby-keyword kw\">else</span>\n\
      448:                 <span class=\"ruby-comment cmt\">#self.log.debug &quot;Already have a attribute named %p&quot; % node.name</span>\n\
      449:             <span class=\"ruby-keyword kw\">end</span>\n\
      450:         <span class=\"ruby-keyword kw\">end</span>\n\
      451:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Install the given <tt>node</tt> into the template object.
      </p>
    params: ( node )
  - visibility: public
    aref: M000454
    name: install_syntax_tree
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 431</span>\n\
      431:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">install_syntax_tree</span>( <span class=\"ruby-identifier\">tree</span> )\n\
      432:         <span class=\"ruby-ivar\">@syntax_tree</span> = <span class=\"ruby-identifier\">tree</span>\n\
      433:         <span class=\"ruby-ivar\">@syntax_tree</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">node</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">add_to_template</span>(<span class=\"ruby-keyword kw\">self</span>) <span class=\"ruby-keyword kw\">end</span>\n\
      434:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Install a <a href="Template.html#M000448">new</a> syntax tree in the
      template object, replacing the old one, if any.
      </p>
    params: ( tree )
  - visibility: public
    aref: M000465
    name: make_rendering_scope
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 545</span>\n\
      545:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">make_rendering_scope</span>\n\
      546:         <span class=\"ruby-comment cmt\"># self.log.debug &quot;Making rendering scope with attributes: %p&quot; % [@attributes]</span>\n\
      547:         <span class=\"ruby-identifier\">scope</span> = <span class=\"ruby-constant\">RenderingScope</span>.<span class=\"ruby-identifier\">new</span>( <span class=\"ruby-ivar\">@attributes</span> )\n\
      548:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">scope</span>\n\
      549:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create an anonymous module to act as a scope for any evals that take place
      during a single <a href="Template.html#M000460">render</a>.
      </p>
    params: ()
  - visibility: public
    aref: M000452
    name: memsize
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 412</span>\n\
      412:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">memsize</span>\n\
      413:         <span class=\"ruby-ivar\">@source</span> <span class=\"ruby-operator\">?</span> <span class=\"ruby-ivar\">@source</span>.<span class=\"ruby-identifier\">length</span> <span class=\"ruby-operator\">:</span> <span class=\"ruby-value\">0</span>\n\
      414:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Return the approximate size of the template, in bytes. Used by <a
      href="Cache.html">Arrow::Cache</a> for size thresholds.
      </p>
    params: ()
  - visibility: public
    aref: M000453
    name: parse
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 419</span>\n\
      419:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">parse</span>( <span class=\"ruby-identifier\">source</span> )\n\
      420:         <span class=\"ruby-ivar\">@source</span> = <span class=\"ruby-identifier\">source</span>\n\
      421:         <span class=\"ruby-identifier\">parserClass</span> = <span class=\"ruby-ivar\">@config</span>[<span class=\"ruby-identifier\">:parserClass</span>]\n\
      422:         <span class=\"ruby-identifier\">tree</span> = <span class=\"ruby-identifier\">parserClass</span>.<span class=\"ruby-identifier\">new</span>( <span class=\"ruby-ivar\">@config</span> ).<span class=\"ruby-identifier\">parse</span>( <span class=\"ruby-identifier\">source</span>, <span class=\"ruby-keyword kw\">self</span> )\n\
      423: \n\
      424:         <span class=\"ruby-comment cmt\">#self.log.debug &quot;Parse complete: syntax tree is: %p&quot; % tree</span>\n\
      425:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">install_syntax_tree</span>( <span class=\"ruby-identifier\">tree</span> )\n\
      426:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Parse the given template source (a String) and put the resulting nodes into
      the template&#8216;s syntax_tree.
      </p>
    params: ( source )
  - visibility: public
    aref: M000463
    name: postrender
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 532</span>\n\
      532:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">postrender</span>( <span class=\"ruby-identifier\">enclosing_template</span>=<span class=\"ruby-keyword kw\">nil</span> )\n\
      533:         <span class=\"ruby-ivar\">@syntax_tree</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">node</span><span class=\"ruby-operator\">|</span>\n\
      534:             <span class=\"ruby-comment cmt\"># self.log.debug &quot;    post-rendering %p&quot; % [node]</span>\n\
      535:             <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">after_rendering</span>( <span class=\"ruby-keyword kw\">self</span> ) <span class=\"ruby-keyword kw\">if</span>\n\
      536:                 <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">respond_to?</span>( <span class=\"ruby-identifier\">:after_rendering</span> )\n\
      537:         <span class=\"ruby-keyword kw\">end</span>\n\
      538:         <span class=\"ruby-ivar\">@enclosing_templates</span>.<span class=\"ruby-identifier\">pop</span>\n\
      539:     <span class=\"ruby-keyword kw\">end</span>"
    aka: 
    - aref: Template.html#M000464
      name: after_rendering
    m_desc: |-
      <p>
      Clean up after template rendering, calling each of its nodes&#8217; <a
      href="Template.html#M000464">#after_rendering</a> hook.
      </p>
    params: ( enclosing_template=nil )
  - visibility: public
    aref: M000462
    name: postrender_done?
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 525</span>\n\
      525:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">postrender_done?</span>\n\
      526:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-ivar\">@postrender_done</span>\n\
      527:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Returns <tt>true</tt> if this template has already been through a post-<a
      href="Template.html#M000460">render</a>.
      </p>
    params: ()
  - visibility: public
    aref: M000458
    name: prerender
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 480</span>\n\
      480:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">prerender</span>( <span class=\"ruby-identifier\">enclosing_template</span>=<span class=\"ruby-keyword kw\">nil</span> )\n\
      481:         <span class=\"ruby-ivar\">@enclosing_templates</span> <span class=\"ruby-operator\">&lt;&lt;</span> <span class=\"ruby-identifier\">enclosing_template</span>\n\
      482: \n\
      483:         <span class=\"ruby-ivar\">@syntax_tree</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">node</span><span class=\"ruby-operator\">|</span>\n\
      484:             <span class=\"ruby-comment cmt\"># self.log.debug &quot;    pre-rendering %p&quot; % [node]</span>\n\
      485:             <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">before_rendering</span>( <span class=\"ruby-keyword kw\">self</span> ) <span class=\"ruby-keyword kw\">if</span>\n\
      486:                 <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">respond_to?</span>( <span class=\"ruby-identifier\">:before_rendering</span> )\n\
      487:         <span class=\"ruby-keyword kw\">end</span>\n\
      488:     <span class=\"ruby-keyword kw\">end</span>"
    aka: 
    - aref: Template.html#M000459
      name: before_rendering
    m_desc: |-
      <p>
      Prep the template for rendering, calling each of its nodes&#8217; <a
      href="Template.html#M000459">#before_rendering</a> hook.
      </p>
    params: ( enclosing_template=nil )
  - visibility: public
    aref: M000457
    name: prerender_done?
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 473</span>\n\
      473:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">prerender_done?</span>\n\
      474:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-ivar\">@prerender_done</span>\n\
      475:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Returns <tt>true</tt> if this template has already been through a pre-<a
      href="Template.html#M000460">render</a>.
      </p>
    params: ()
  - visibility: public
    aref: M000460
    name: render
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 500</span>\n\
      500:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">render</span>( <span class=\"ruby-identifier\">nodes</span>=<span class=\"ruby-keyword kw\">nil</span>, <span class=\"ruby-identifier\">scope</span>=<span class=\"ruby-keyword kw\">nil</span>, <span class=\"ruby-identifier\">enclosing_template</span>=<span class=\"ruby-keyword kw\">nil</span> )\n\
      501:         <span class=\"ruby-identifier\">rval</span> = []\n\
      502:         <span class=\"ruby-identifier\">nodes</span> <span class=\"ruby-operator\">||=</span> <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">get_prepped_nodes</span>\n\
      503:         <span class=\"ruby-identifier\">scope</span> <span class=\"ruby-operator\">||=</span> <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">make_rendering_scope</span>\n\
      504:         \n\
      505:         <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">prerender</span>( <span class=\"ruby-identifier\">enclosing_template</span> )\n\
      506: \n\
      507:         <span class=\"ruby-comment cmt\"># Render each node</span>\n\
      508:         <span class=\"ruby-identifier\">nodes</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">node</span><span class=\"ruby-operator\">|</span>\n\
      509:             <span class=\"ruby-comment cmt\"># self.log.debug &quot;  rendering %p&quot; % [ node ]</span>\n\
      510:             <span class=\"ruby-keyword kw\">begin</span>\n\
      511:                 <span class=\"ruby-identifier\">rval</span> <span class=\"ruby-operator\">&lt;&lt;</span> <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">render</span>( <span class=\"ruby-keyword kw\">self</span>, <span class=\"ruby-identifier\">scope</span> )\n\
      512:             <span class=\"ruby-keyword kw\">rescue</span> <span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Exception</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">err</span>\n\
      513:                 <span class=\"ruby-identifier\">rval</span> <span class=\"ruby-operator\">&lt;&lt;</span> <span class=\"ruby-identifier\">err</span>\n\
      514:             <span class=\"ruby-keyword kw\">end</span>\n\
      515:         <span class=\"ruby-keyword kw\">end</span>\n\
      516: \n\
      517:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">render_objects</span>( <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">rval</span> )\n\
      518:     <span class=\"ruby-keyword kw\">ensure</span>\n\
      519:         <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">postrender</span>\n\
      520:     <span class=\"ruby-keyword kw\">end</span>"
    aka: 
    - aref: Template.html#M000461
      name: to_s
    m_desc: |-
      <p>
      Render the template to text and return it as a String. If called with an
      Array of <tt>nodes</tt>, the template will <a
      href="Template.html#M000460">render</a> them instead of its own
      syntax_tree. If given a scope (a <a href="../Module.html">Module</a>
      object), a Binding of its internal state it will be used as the context of
      evaluation for the <a href="Template.html#M000460">render</a>. If not
      specified, a <a href="Template.html#M000448">new</a> anonymous <a
      href="../Module.html">Module</a> instance is created for the <a
      href="Template.html#M000460">render</a>. If a <tt>enclosing_template</tt>
      is given, make it available during rendering for variable-sharing, etc.
      Returns the results of each nodes&#8217; <a
      href="Template.html#M000460">render</a> joined together with the default
      string separator (+$,+).
      </p>
    params: ( nodes=nil, scope=nil, enclosing_template=nil )
  - visibility: public
    aref: M000467
    name: render_comment
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 584</span>\n\
      584:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">render_comment</span>( <span class=\"ruby-identifier\">message</span> )\n\
      585:         <span class=\"ruby-identifier\">comment</span> = <span class=\"ruby-value str\">&quot;%s%s%s\\n&quot;</span> <span class=\"ruby-operator\">%</span> [\n\
      586:             <span class=\"ruby-ivar\">@config</span>[<span class=\"ruby-identifier\">:commentStart</span>],\n\
      587:             <span class=\"ruby-identifier\">message</span>,\n\
      588:             <span class=\"ruby-ivar\">@config</span>[<span class=\"ruby-identifier\">:commentEnd</span>],\n\
      589:         ]\n\
      590:         <span class=\"ruby-comment cmt\">#self.log.debug &quot;Rendered comment: %s&quot; % comment</span>\n\
      591:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">comment</span>\n\
      592:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Render the given <tt>message</tt> as a comment as specified by the template
      configuration.
      </p>
    params: ( message )
  - visibility: public
    aref: M000466
    name: render_objects
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 553</span>\n\
      553:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">render_objects</span>( <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">objs</span> )\n\
      554:         <span class=\"ruby-identifier\">objs</span>.<span class=\"ruby-identifier\">collect</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">obj</span><span class=\"ruby-operator\">|</span>\n\
      555:             <span class=\"ruby-identifier\">rval</span> = <span class=\"ruby-keyword kw\">nil</span>\n\
      556:             <span class=\"ruby-identifier\">key</span> = (<span class=\"ruby-ivar\">@renderers</span>.<span class=\"ruby-identifier\">keys</span> <span class=\"ruby-operator\">&amp;</span> <span class=\"ruby-identifier\">obj</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">ancestors</span>).<span class=\"ruby-identifier\">sort</span> {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">a</span>,<span class=\"ruby-identifier\">b</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">a</span> <span class=\"ruby-operator\">&lt;=&gt;</span> <span class=\"ruby-identifier\">b</span>}.<span class=\"ruby-identifier\">first</span>\n\
      557: \n\
      558:             <span class=\"ruby-keyword kw\">begin</span>\n\
      559:                 <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">key</span>\n\
      560:                     <span class=\"ruby-keyword kw\">case</span> <span class=\"ruby-ivar\">@renderers</span>[ <span class=\"ruby-identifier\">key</span> ]\n\
      561:                     <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-constant\">Proc</span>, <span class=\"ruby-constant\">Method</span>\n\
      562:                         <span class=\"ruby-identifier\">rval</span> = <span class=\"ruby-ivar\">@renderers</span>[ <span class=\"ruby-identifier\">key</span> ].<span class=\"ruby-identifier\">call</span>( <span class=\"ruby-identifier\">obj</span>, <span class=\"ruby-keyword kw\">self</span> )\n\
      563:                     <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-constant\">Symbol</span>\n\
      564:                         <span class=\"ruby-identifier\">methodname</span> = <span class=\"ruby-ivar\">@renderers</span>[ <span class=\"ruby-identifier\">key</span> ]\n\
      565:                         <span class=\"ruby-identifier\">rval</span> = <span class=\"ruby-identifier\">obj</span>.<span class=\"ruby-identifier\">send</span>( <span class=\"ruby-identifier\">methodname</span> )\n\
      566:                     <span class=\"ruby-keyword kw\">else</span>\n\
      567:                         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">TypeError</span>, <span class=\"ruby-value str\">&quot;Unknown renderer type '%s' for %p&quot;</span> <span class=\"ruby-operator\">%</span>\n\
      568:                             [ <span class=\"ruby-ivar\">@renderers</span>[<span class=\"ruby-identifier\">key</span>], <span class=\"ruby-identifier\">obj</span> ]\n\
      569:                     <span class=\"ruby-keyword kw\">end</span>\n\
      570:                 <span class=\"ruby-keyword kw\">else</span>\n\
      571:                     <span class=\"ruby-identifier\">rval</span> = <span class=\"ruby-identifier\">obj</span>.<span class=\"ruby-identifier\">to_s</span>\n\
      572:                 <span class=\"ruby-keyword kw\">end</span>\n\
      573:             <span class=\"ruby-keyword kw\">rescue</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">err</span>\n\
      574:                 <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">error</span> <span class=\"ruby-value str\">&quot;rendering error while rendering %p (a %s): %s&quot;</span> <span class=\"ruby-operator\">%</span> \n\
      575:                     [<span class=\"ruby-identifier\">obj</span>, <span class=\"ruby-identifier\">obj</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">err</span>.<span class=\"ruby-identifier\">message</span>]\n\
      576:                 <span class=\"ruby-ivar\">@renderers</span>[ <span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Exception</span> ].<span class=\"ruby-identifier\">call</span>( <span class=\"ruby-identifier\">err</span>, <span class=\"ruby-keyword kw\">self</span> )\n\
      577:             <span class=\"ruby-keyword kw\">end</span>\n\
      578:         <span class=\"ruby-keyword kw\">end</span>.<span class=\"ruby-identifier\">join</span>\n\
      579:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Render the specified objects into text.
      </p>
    params: ( *objs )
  - visibility: public
    aref: M000461
    name: to_s
    m_desc: |-
      <p>
      Alias for <a href="Template.html#M000460">#render</a>
      </p>
    params: ( nodes=nil, scope=nil, enclosing_template=nil )
  - visibility: public
    aref: M000468
    name: with_overridden_attributes
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 598</span>\n\
      598:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">with_overridden_attributes</span>( <span class=\"ruby-identifier\">scope</span>, <span class=\"ruby-identifier\">hash</span> )\n\
      599:         <span class=\"ruby-identifier\">oldvals</span> = {}\n\
      600:         <span class=\"ruby-keyword kw\">begin</span>\n\
      601:             <span class=\"ruby-identifier\">hash</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">value</span><span class=\"ruby-operator\">|</span>\n\
      602:                 <span class=\"ruby-comment cmt\">#self.log.debug &quot;Overriding attribute %s with value: %p&quot; %</span>\n\
      603:                 <span class=\"ruby-comment cmt\">#   [ name, value ]</span>\n\
      604:                 <span class=\"ruby-identifier\">oldvals</span>[<span class=\"ruby-identifier\">name</span>] = <span class=\"ruby-ivar\">@attributes</span>.<span class=\"ruby-identifier\">key?</span>( <span class=\"ruby-identifier\">name</span> ) <span class=\"ruby-operator\">?</span> <span class=\"ruby-ivar\">@attributes</span>[ <span class=\"ruby-identifier\">name</span> ] <span class=\"ruby-operator\">:</span> <span class=\"ruby-keyword kw\">nil</span>\n\
      605:                 <span class=\"ruby-ivar\">@attributes</span>[ <span class=\"ruby-identifier\">name</span> ] = <span class=\"ruby-identifier\">value</span>\n\
      606:             <span class=\"ruby-keyword kw\">end</span>\n\
      607:             <span class=\"ruby-identifier\">scope</span>.<span class=\"ruby-identifier\">override</span>( <span class=\"ruby-identifier\">hash</span> ) <span class=\"ruby-keyword kw\">do</span>\n\
      608:                 <span class=\"ruby-keyword kw\">yield</span>( <span class=\"ruby-keyword kw\">self</span> )\n\
      609:             <span class=\"ruby-keyword kw\">end</span>\n\
      610:         <span class=\"ruby-keyword kw\">ensure</span>\n\
      611:             <span class=\"ruby-identifier\">oldvals</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">value</span><span class=\"ruby-operator\">|</span>\n\
      612:                 <span class=\"ruby-comment cmt\">#self.log.debug &quot;Restoring old value: %s for attribute %p&quot; %</span>\n\
      613:                 <span class=\"ruby-comment cmt\">#   [ name, value ]</span>\n\
      614:                 <span class=\"ruby-ivar\">@attributes</span>.<span class=\"ruby-identifier\">delete</span>( <span class=\"ruby-identifier\">name</span> )\n\
      615:                 <span class=\"ruby-ivar\">@attributes</span>[ <span class=\"ruby-identifier\">name</span> ] = <span class=\"ruby-identifier\">oldvals</span>[<span class=\"ruby-identifier\">name</span>] <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">oldvals</span>[<span class=\"ruby-identifier\">name</span>]\n\
      616:             <span class=\"ruby-keyword kw\">end</span>\n\
      617:         <span class=\"ruby-keyword kw\">end</span>\n\
      618:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Call the given <tt>block</tt>, overriding the contents of the
      template&#8216;s attributes and the definitions in the specified
      <tt>scope</tt> with those from the pairs in the given <tt>hash</tt>.
      </p>
    params: ( scope, hash ) {|self| ...}
  category: Instance
  type: Public
- methods: 
  - visibility: protected
    aref: M000472
    name: add_attribute_accessor
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 698</span>\n\
      698:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">add_attribute_accessor</span>( <span class=\"ruby-identifier\">sym</span> )\n\
      699:         <span class=\"ruby-identifier\">name</span> = <span class=\"ruby-identifier\">sym</span>.<span class=\"ruby-identifier\">to_s</span>.<span class=\"ruby-identifier\">sub</span>( <span class=\"ruby-regexp re\">/=$/</span>, <span class=\"ruby-value str\">''</span> )\n\
      700: \n\
      701:         <span class=\"ruby-identifier\">code</span> = <span class=\"ruby-node\">%Q{\n\
      702:             def self::#{name}\n\
      703:                 @attributes[#{name.inspect}]\n\
      704:             end\n\
      705:         }</span>\n\
      706: \n\
      707:         <span class=\"ruby-comment cmt\"># $stderr.puts &quot;Auto-defining accessor for #{name}: #{code}&quot;</span>\n\
      708:         <span class=\"ruby-identifier\">eval</span>( <span class=\"ruby-identifier\">code</span>, <span class=\"ruby-keyword kw\">nil</span>, <span class=\"ruby-node\">&quot;#{name} [Auto-defined]&quot;</span>, <span class=\"ruby-keyword kw\">__LINE__</span> )\n\
      709:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Add a singleton accessor (getter) method for accessing the attribute
      specified by <tt>sym</tt> to the receiver.
      </p>
    params: ( sym )
  - visibility: protected
    aref: M000473
    name: add_attribute_mutator
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 714</span>\n\
      714:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">add_attribute_mutator</span>( <span class=\"ruby-identifier\">sym</span> )\n\
      715:         <span class=\"ruby-identifier\">name</span> = <span class=\"ruby-identifier\">sym</span>.<span class=\"ruby-identifier\">to_s</span>.<span class=\"ruby-identifier\">sub</span>( <span class=\"ruby-regexp re\">/=$/</span>, <span class=\"ruby-value str\">''</span> )\n\
      716: \n\
      717:         <span class=\"ruby-identifier\">code</span> = <span class=\"ruby-node\">%Q{\n\
      718:             def self::#{name}=( arg )\n\
      719:                 @attributes[ #{name.inspect} ] = arg\n\
      720:             end\n\
      721:         }</span>\n\
      722: \n\
      723:         <span class=\"ruby-comment cmt\"># $stderr.puts &quot;Auto-defining mutator for #{name}: #{code}&quot;</span>\n\
      724:         <span class=\"ruby-identifier\">eval</span>( <span class=\"ruby-identifier\">code</span>, <span class=\"ruby-keyword kw\">nil</span>, <span class=\"ruby-node\">&quot;#{name}= [Auto-defined]&quot;</span>, <span class=\"ruby-keyword kw\">__LINE__</span> )\n\
      725:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Add a singleton mutator (setter) method for accessing the attribute
      specified by <tt>sym</tt> to the receiver.
      </p>
    params: ( sym )
  - visibility: protected
    aref: M000469
    name: get_prepped_nodes
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 628</span>\n\
      628:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">get_prepped_nodes</span>\n\
      629:         <span class=\"ruby-identifier\">tree</span> = <span class=\"ruby-ivar\">@syntax_tree</span>.<span class=\"ruby-identifier\">dup</span>\n\
      630: \n\
      631:         <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">strip_directive_whitespace</span>( <span class=\"ruby-identifier\">tree</span> ) <span class=\"ruby-keyword kw\">if</span>\n\
      632:           <span class=\"ruby-ivar\">@config</span>[<span class=\"ruby-identifier\">:elideDirectiveLines</span>]\n\
      633: \n\
      634:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">tree</span>\n\
      635:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Returns the syntax tree with its nodes prerendered in accordance with the
      template&#8216;s configuration.
      </p>
    params: ()
  - visibility: protected
    aref: M000471
    name: method_missing
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 674</span>\n\
      674:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">method_missing</span>( <span class=\"ruby-identifier\">sym</span>, <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">args</span>, <span class=\"ruby-operator\">&amp;</span><span class=\"ruby-identifier\">block</span> )\n\
      675:         <span class=\"ruby-identifier\">name</span> = <span class=\"ruby-identifier\">sym</span>.<span class=\"ruby-identifier\">to_s</span>.<span class=\"ruby-identifier\">gsub</span>( <span class=\"ruby-regexp re\">/=$/</span>, <span class=\"ruby-value str\">''</span> )\n\
      676:         <span class=\"ruby-keyword kw\">super</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-ivar\">@attributes</span>.<span class=\"ruby-identifier\">key?</span>( <span class=\"ruby-identifier\">name</span> ) <span class=\"ruby-operator\">||</span> <span class=\"ruby-operator\">!</span><span class=\"ruby-ivar\">@config</span>[<span class=\"ruby-identifier\">:strictAttributes</span>]\n\
      677: \n\
      678:         <span class=\"ruby-comment cmt\">#self.log.debug &quot;Autoloading for #{sym}&quot;</span>\n\
      679: \n\
      680:         <span class=\"ruby-comment cmt\"># Mutator</span>\n\
      681:         <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-regexp re\">/=$/</span> <span class=\"ruby-operator\">=~</span> <span class=\"ruby-identifier\">sym</span>.<span class=\"ruby-identifier\">to_s</span>\n\
      682:             <span class=\"ruby-comment cmt\">#self.log.debug &quot;Autoloading mutator %p&quot; % sym</span>\n\
      683:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">add_attribute_mutator</span>( <span class=\"ruby-identifier\">sym</span> )\n\
      684:         <span class=\"ruby-comment cmt\"># Accessor</span>\n\
      685:         <span class=\"ruby-keyword kw\">else</span>\n\
      686:             <span class=\"ruby-comment cmt\">#self.log.debug &quot;Autoloading accessor %p&quot; % sym</span>\n\
      687:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">add_attribute_accessor</span>( <span class=\"ruby-identifier\">sym</span> )\n\
      688:         <span class=\"ruby-keyword kw\">end</span>\n\
      689: \n\
      690:         <span class=\"ruby-comment cmt\"># Don't use #send to avoid infinite recursion in case method</span>\n\
      691:         <span class=\"ruby-comment cmt\"># definition has failed for some reason.</span>\n\
      692:         <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">method</span>( <span class=\"ruby-identifier\">sym</span> ).<span class=\"ruby-identifier\">call</span>( <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">args</span> )\n\
      693:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Autoload accessor/mutator methods for attributes.
      </p>
    params: ( sym, *args, &amp;block )
  - visibility: protected
    aref: M000470
    name: strip_directive_whitespace
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template.rb, line 641</span>\n\
      641:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">strip_directive_whitespace</span>( <span class=\"ruby-identifier\">tree</span> )\n\
      642:         <span class=\"ruby-comment cmt\"># Make a flat list of all nodes</span>\n\
      643:         <span class=\"ruby-identifier\">nodes</span> = <span class=\"ruby-identifier\">tree</span>.<span class=\"ruby-identifier\">collect</span> {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">node</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">to_a</span>}.<span class=\"ruby-identifier\">flatten</span>\n\
      644: \n\
      645:         <span class=\"ruby-comment cmt\"># Elide non-rendering directive lines. Match node lists like:</span>\n\
      646:         <span class=\"ruby-comment cmt\">#   &lt;TextNode&gt; =~ /\\n\\s*$/</span>\n\
      647:         <span class=\"ruby-comment cmt\">#   &lt;NonRenderingNode&gt;*</span>\n\
      648:         <span class=\"ruby-comment cmt\">#   &lt;TextNode&gt; =~ /^\\n/</span>\n\
      649:         <span class=\"ruby-comment cmt\"># removing one &quot;\\n&quot; from the tail of the leading textnode and the</span>\n\
      650:         <span class=\"ruby-comment cmt\"># head of the trailing textnode. Trailing textnode can also be a</span>\n\
      651:         <span class=\"ruby-comment cmt\"># leading textnode for another series.</span>\n\
      652:         <span class=\"ruby-identifier\">nodes</span>.<span class=\"ruby-identifier\">each_with_index</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">node</span>,<span class=\"ruby-identifier\">i</span><span class=\"ruby-operator\">|</span>\n\
      653:             <span class=\"ruby-identifier\">leadingNode</span> = <span class=\"ruby-identifier\">nodes</span>[<span class=\"ruby-identifier\">i</span><span class=\"ruby-operator\">-</span><span class=\"ruby-value\">1</span>]\n\
      654: \n\
      655:             <span class=\"ruby-comment cmt\"># If both the leading node and the current one match the</span>\n\
      656:             <span class=\"ruby-comment cmt\"># criteria, look for a trailing node.</span>\n\
      657:             <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">i</span>.<span class=\"ruby-identifier\">nonzero?</span> <span class=\"ruby-operator\">&amp;&amp;</span> <span class=\"ruby-identifier\">leadingNode</span>.<span class=\"ruby-identifier\">is_a?</span>( <span class=\"ruby-constant\">TextNode</span> ) <span class=\"ruby-operator\">&amp;&amp;</span>\n\
      658:                     <span class=\"ruby-identifier\">leadingNode</span> <span class=\"ruby-operator\">=~</span> <span class=\"ruby-regexp re\">/\\n\\s*$/s</span>\n\
      659: \n\
      660:                 <span class=\"ruby-comment cmt\"># Find the trailing node. Abandon the search on any</span>\n\
      661:                 <span class=\"ruby-comment cmt\"># rendering directive or text node that includes a blank line.</span>\n\
      662:                 <span class=\"ruby-identifier\">trailingNode</span> = <span class=\"ruby-identifier\">nodes</span>[<span class=\"ruby-identifier\">i</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">-1</span>].<span class=\"ruby-identifier\">find</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">node</span><span class=\"ruby-operator\">|</span>\n\
      663:                     <span class=\"ruby-keyword kw\">break</span> <span class=\"ruby-keyword kw\">nil</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">rendering?</span>\n\
      664:                     <span class=\"ruby-identifier\">node</span>.<span class=\"ruby-identifier\">is_a?</span>( <span class=\"ruby-constant\">TextNode</span> ) <span class=\"ruby-operator\">&amp;&amp;</span> <span class=\"ruby-identifier\">node</span> <span class=\"ruby-operator\">=~</span> <span class=\"ruby-regexp re\">/^\\n/</span>\n\
      665:                 <span class=\"ruby-keyword kw\">end</span>\n\
      666: \n\
      667:                 <span class=\"ruby-identifier\">leadingNode</span>.<span class=\"ruby-identifier\">body</span>.<span class=\"ruby-identifier\">sub!</span>( <span class=\"ruby-regexp re\">/\\n\\s*$/</span>, <span class=\"ruby-value str\">''</span> ) <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">trailingNode</span>\n\
      668:             <span class=\"ruby-keyword kw\">end</span>\n\
      669:         <span class=\"ruby-keyword kw\">end</span>\n\
      670:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Strip whitespace from the tails of textnodes before and the head of
      textnodes after lines consisting only of non-rendering directives in the
      given template syntax <tt>tree</tt>.
      </p>
    params: ( tree )
  category: Instance
  type: Protected

sectitle

--- 

constants

--- 
- name: SVNRev
  desc: |+
    
    SVN Revision
    
  value: "%q$Rev: 440 $"
- name: SVNId
  desc: |+
    
    SVN Id
    
  value: "%q$Id: template.rb 440 2008-04-16 14:59:26Z deveiant $"
- name: Defaults
  desc: |+
    
    Configuration defaults. Valid members are the same as those listed for the
    <tt>config</tt> item of the <a href="Template.html#M000448">#new</a>
    method.
    
  value: "{         :parserClass          =&gt; Arrow::Template::Parser,         :elideDirectiveLines  =&gt; true,         :debuggingComments        =&gt; false,         :commentStart         =&gt; '&lt;!-- ',         :commentEnd               =&gt; ' --&gt;',         :strictAttributes     =&gt; false,     }"
- name: DefaultRenderers
  desc: |+
    
    A Hash which specifies the default renderers for different classes of
    objects.
    
  value: "{         Arrow::Template   =&gt; lambda {|subtempl,templ|             subtempl.render( nil, nil, templ )"

[Validate]

Generated with the Darkfish Rdoc Generator.