Sha256: b5babb566830010c98260996b7564350c6f5be62e2a3aa9342c720c4ff040ee4

Contents?: true

Size: 601 Bytes

Versions: 2

Compression:

Stored size: 601 Bytes

Contents

module Munge
  module Helper
    module Link
      def url_for(item)
        @router.route(item)
      end

      def link_to(item, text = nil, opts = {})
        link = url_for(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.5.0 lib/munge/helper/link.rb
munge-0.5.0.beta1 lib/munge/helper/link.rb