Class: CSL::Nodes::Substitute

Inherits:
Node
  • Object
show all
Defined in:
lib/csl/nodes.rb

Overview

The optional cs:substitute element, which should be included as the last child element of cs:names, controls substitution in case the name variables specified in the parent cs:names element are empty. The substitutions are specified as child elements of cs:substitute, and can consist of any of the standard rendering elements (with the exception of cs:layout). It is also possible to use a shorthand version of cs:names, which doesn’t allow for any child elements, and uses the attributes values set on the cs:name and cs:et-al child elements of the original cs:names element. If cs:substitute contains multiple child elements, the first element to return a non-empty result is used for substitution. Substituted variables are repressed in the rest of the output to prevent duplication. An example, where an empty “author” name variable is substituted by the “editor” name variable, or, when no editors exist, by the “title” macro:

<macro name="author">
  <names variable="author">
    <name/>
    <substitute>
      <names variable="editor"/>
      <text macro="title"/>
    </substitute>
  </names>
</macro>

Instance Attribute Summary

Attributes inherited from Node

#style

Attributes included from Support::Tree

#node_name, #parent

Attributes included from Support::Attributes

#attributes, #key_filter, #value_filter

Instance Method Summary collapse

Methods inherited from Node

#copy, #evaluate, format_on, #initialize, #localized_date_parts, #localized_options, #localized_terms, #merge, #parse, #reverse_merge, #to_s

Methods included from Support::Tree

#add_children, #ancestors, #ancestors!, #children, #depth, #descendants, #descendants!, #each, #find_children_by_name, #has_children?, included, #name, #root, #root!, #root?

Methods included from Support::Attributes

#[], #[]=, included, #merge, #reverse_merge

Constructor Details

This class inherits a constructor from CSL::Nodes::Node

Instance Method Details

#process(data, processor) ⇒ Object



993
994
995
996
997
998
999
1000
1001
1002
# File 'lib/csl/nodes.rb', line 993

def process(data, processor)
  super
  children.each do |child|
    processed = child.process(data, processor)
    return processed unless processed.empty?
  end
  ''
rescue Exception => e
  handle_processing_error(e, data, processor)        
end