Class: Webgen::Tag::Link

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/webgen/tag/link.rb

Overview

Create a link to a given (A)LCN.

Instance Method Summary collapse

Methods included from Base

#create_params_hash, #create_tag_params, #param, #set_params

Methods included from WebsiteAccess

included, website

Methods included from Loggable

#log, #puts

Instance Method Details

#call(tag, body, context) ⇒ Object

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



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

def call(tag, body, context)
  if (dest_node = context.ref_node.resolve(param('tag.link.path').to_s, context.dest_node.lang))
    context.dest_node.node_info[:used_meta_info_nodes] << dest_node.alcn
    context.dest_node.link_to(dest_node, param('tag.link.attr').merge(:lang => context.content_node.lang))
  else
    raise ArgumentError, 'Resolving of path failed'
  end
rescue ArgumentError, URI::InvalidURIError => e
  log(:error) { "Could not link to path '#{param('tag.link.path')}' in <#{context.ref_node.alcn}>: #{e.message}" }
  context.dest_node.flag(:dirty)
  ''
end