Method: Webgen::Tree#resolve_node
- Defined in:
- lib/webgen/tree.rb
#resolve_node(path, lang, msg_on_failure = false) ⇒ Object
Return the node representing the given path which can be an alcn/acn/destination path (name resolution is done in the specified order). The path has to be absolute, i.e. starting with a slash.
If the path is an alcn and a node is found, it is returned. If the path is an acn, the correct localized node according to lang is returned or if no such node exists but an unlocalized version does, the unlocalized node is returned. If the path is a destination path, the node with this destination path is returned.
If no node is found for the given path or if the path is invalid, nil is returned and, if msg_on_failure is true, the message :node_resolution_failed (with parameters path and lang) is dispatched.
72 73 74 75 76 77 78 79 80 |
# File 'lib/webgen/tree.rb', line 72 def resolve_node(path, lang, msg_on_failure = false) node = self.node(path, :alcn) if !node || node.acn == path (node = (self.node(path, :acn) || self.node(path + '/', :acn))) && (node = translate_node(node, lang)) end node = self.node(path, :dest_path) if !node @website.blackboard.dispatch_msg(:node_resolution_failed, path, lang) if !node && msg_on_failure node end |