Sha256: 4755122f2ec0896fcde3d446f95351945520316bc1a90f38b9ed3b4dafc7a5e2

Contents?: true

Size: 602 Bytes

Versions: 2

Compression:

Stored size: 602 Bytes

Contents

module Munge
  module Helpers
    module Link
      def path_to(item)
        @router.route(item)
      end

      def link_to(item, text = nil, opts = {})
        link = path_to(item)

        if text.is_a?(Hash)
          opts = text
          text = nil
        end

        optstr = opts.map { |key, val| %(#{key}="#{val}") }

        parts =
          [
            [
              "<a",
              %(href="#{link}"),
              optstr
            ].flatten.join(" "),
            ">",
            text || link,
            "</a>"
          ]

        parts.join
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
munge-0.11.1 lib/munge/helpers/link.rb
munge-0.11.0 lib/munge/helpers/link.rb