A node is a block of text that appears like this:
<% node_type node_argument1, node_argument2, ... do |node_object| %>
node_content
<% end %>
Or like this:
<% node_type node_argument1, node_argument2, ... do %>
node_content
<% end %>
Or like this:
<%= node_type node_argument1, node_argument2, ... %>
Alternatively, you may omit the leading ”<” and trailing “%>” characters from an eRuby directive if the directive spans an entire line. So, the above examples become:
% node_type node_argument1, node_argument2, ... do |node_object|
node_content
% end
And:
% node_type node_argument1, node_argument2, ... do
node_content
% end
And:
%= node_type node_argument1, node_argument2, ...
Technically, nodes are Ruby method invocations composed of the following:
Component | Description |
---|
node_type | name of the method being invoked |
node_argument1, node_argument2, ... | arguments for the method invocation |
node_content | a block argument being passed to the method invocation |
node_object | a ERBook::Node object (see Section 3.1.1. The ERBook::Node class) representing this method invocation |
A format specification file defines what types of nodes an input document may use.
When erbook builds a document tree from the nodes in an input document, it stores information about these nodes into ERBook::Node
objects. A ERBook::Node
object has the following properties (methods):
Property | Type | Description |
---|
type | String | Name of the type of this node. |
args | Array | Arguments passed to this node. |
content | String | The block of text passed to this node. |
output | String | Result of the node output template for the content of this node. |
digest | String | A unique identifier for the content of this node. |
trace | Array | A stack trace describing the location of this node in the input document. |
index | String | A LaTeX-style section number for this node. This property is only present if the index parameter is enabled in the definition of this type of node. |
number | Integer | An order-of-occurrence number for this node. This property is only present if the number parameter is enabled in the definition of this type of node. |
depth | Integer | Distance from the root of the document tree to this node. |
parent | ERBook::Node | The ERBook::Node object which contains this node. The value of this property will be nil if this node is a root of the document tree. |
children | Array of ERBook::Node | List of child nodes from the document tree. |
Furthermore, the ERBook::Node
class is derived from Ruby’s OpenStruct
class, so you can define new properties for ERBook::Node
objects dynamically.