Sha256: ebc1141b238b43be4534bb1d5ff1bcd873eb044233f41a0ccdaf9e4036ccc0c6

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

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'), context.dest_node.lang))
        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.absolute_lcn}>: #{e.message}" }
      context.dest_node.flag(:dirty)
      ''
    end

  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.6.20081020 lib/webgen/tag/link.rb
webgen-0.5.6 lib/webgen/tag/link.rb