Sha256: 3abc14b3bc8f00cd55987aac249623644fca9de2471c2600ce60ca3684b56bac

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

# -*- encoding: utf-8 -*-

module Webgen::Tag

  # Create a link to a given (A)LCN.
  class Link

    include Webgen::Tag::Base

    # Return a HTML link to the given (A)LCN.
    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

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gettalong-webgen-0.5.9.20090620 lib/webgen/tag/link.rb
gettalong-webgen-0.5.9.20090626 lib/webgen/tag/link.rb