Sha256: 4dc499418089c943d7407fa73b566e5756c8bc6ba794b60e420baff6f93902de

Contents?: true

Size: 830 Bytes

Versions: 2

Compression:

Stored size: 830 Bytes

Contents

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

module Webgen
  class Tag

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

      # Return an HTML link to the given (A)LCN.
      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.alcn)
          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}",
                                      self.name, context.dest_node, context.ref_node)
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webgen-1.0.0.beta2 lib/webgen/tag/link.rb
webgen-1.0.0.beta1 lib/webgen/tag/link.rb