Method: Asciidoctor::AbstractNode#attr
- Defined in:
- lib/asciidoctor/abstract_node.rb
#attr(name, default_value = nil, fallback_name = nil) ⇒ Object
Get the value of the specified attribute. If the attribute is not found on this node, fallback_name is set, and this node is not the Document node, get the value of the specified attribute from the Document node.
Look for the specified attribute in the attributes on this node and return the value of the attribute, if found. Otherwise, if fallback_name is set (default: same as name) and this node is not the Document node, look for that attribute on the Document node and return its value, if found. Otherwise, return the default value (default: nil).
88 89 90 |
# File 'lib/asciidoctor/abstract_node.rb', line 88 def attr name, default_value = nil, fallback_name = nil @attributes[name.to_s] || (fallback_name && @parent && @document.attributes[(fallback_name == true ? name : fallback_name).to_s] || default_value) end |