Module: Webgen::Tag::Link

Defined in:
lib/webgen/tag/link.rb

Overview

Create a link to a given (A)LCN.

Class Method Summary collapse

Class Method Details

.call(tag, body, context) ⇒ Object

Return an HTML link to the given (A)LCN.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/webgen/tag/link.rb', line 10

def self.call(tag, body, context)
  path = context[:config]['tag.link.path'].to_s
  if (dest_node = context.ref_node.resolve(path, context.dest_node.lang, true))
    context.website.ext.item_tracker.add(context.dest_node, :node_meta_info, dest_node)
    context.dest_node.link_to(dest_node, context.content_node.lang, context[:config]['tag.link.attr'])
  else
    ''
  end
rescue URI::InvalidURIError => e
  raise Webgen::RenderError.new("Error while parsing path '#{path}': #{e.message}",
                                "tag.#{tag}", context.dest_node, context.ref_node)
end